Archive

Posts Tagged ‘graphics’

3D Graphics

December 5, 2008 Leave a comment

Now at www.breakingwave.co.nr – the home of trevorpythag

This is a brief explanation of how to create basic 3D graphics. There are many different packages that will allow you to program using pre written 3D graphics library’s, such as Java 3D but this is aimed at using and understanding the actual formula that can be used to draw the graphics yourself.

This assumes you are looking straight ahead from a single point and will map points in the 3D space in front of you onto a single plane at a fixed distance in front of you, probably 1 unit to keep it simple.

First of all consider the vertical direction, y axis. If we consider the right angled triangle formed by taking the line from you eye to the point, the line from your eye to beneath the point (ie the line where y =0) and the final verical equal to the y cordinate, we can use trigonometry to work out the height that need to be displayed.

From this we can work out the angle at your eye would be tan-1(y/(x2+z2))
This is because the length of the “opposite” is equal to the y co-ordinate and the adjacent can be found using pythagoras from the x and z co-ordinates.

We now can use the angle we have found to work out where the point needs to be displayed in our plane. Again we need to form a triangle similar to the first one but where the top corner is the final position of the point when it is projected. Ie the opposite is the y co-ordinate we need.
therefore,
y = tan(t)((x/z)2+1)
y=y((x/z)2+1)
(x2+z2)

Advertisements

Trevor Changes

February 20, 2008 Leave a comment

Its been a while since i last made some updates to trevor so i have. Ive also included to new levels in the download, although there some digging to do if you want to play the previous levels(there stored as a complied subclass of level, not as a text file in the levels folder).

DOWNLOAD

So what are the changes?

well really only that i have made the movement of trevor much smoother. On the first versions the screen was repainted evrey time the main game loop was run. This meant it could only move one block per frame, making the animation verey jumpy. Now ive made it so that it is repainted 4 times for evrey block he moves, so he moves 5px per frame at 10 frames a second, so the motion looks verey smooth.

Becuase people found the “simple to use” level design method to hard!!!!!!! ive made it even simpler. When your level is read in the borders are automatically added, so all you have to do is make sure your level isnt more than 19 lines high and 59 accorss and add and blank line and then end at the end. Simple!!!

Ive included 2 new levels for you to play. Just change the play.bat file so that it pass the game the level you want to plays file name as a parameter.

Happy trevoring. You can also visit the trevor section my site www.breakingwave.co.nr/computing/trevor/intro.htm

TREVOR PYTHAGORAS + C >> download update

February 7, 2008 Leave a comment

The latest version of trevor is now downloadable. I have made quite a few improvements to it since last time 🙂 and ive made a new level. To download click below, all posts on this blog also have a download on the left or from my site(www.breakingwave.co.nr — ull need to navigate away from the home page to see the trevor link in the nave bar)

DOWNLOAD

 

Whats new?

  • Trevors motion is much smoother. Ive added in frame between each execution loop so the motion appears smooth and less like hes jumping around
  • A scrolling screen. This means the screen follows trevor around the level, displaying 20 blocks either side, opposed to displaying the whole level. This allows much larger levels to be created
  • A text file reader allowing you to write your own levels for trevor in a text file with no knowledge of codeing 🙂

How to create you own level

After downloading trevor you can create your own levels, just follow the simple steps below

  1. Open up a plain text editor – like note pad found in accessories
  2. Each chracter in the file represents a object in the game.
  3. once you have produced you level design leave a blank line and then on the next line type “end”
  4. save you level in the levels folder of trevor
  5. edit the play.bat file to have the name of your level instead of test.lev — rember to put in the file extenstion(probably .txt)
  6. run play.bat

so how do i create objects?

The level can be 59 objects wide(so 59 characters across) and 19 high (so on 19 rows). For an empty space use any key other than the ones specified below. You will need to build a floor and walls using the ground object else the game will crash when trevor leaves the games area (you may also need a ceiling)

object codes:

ground — g
triangle — t
evil fish — >
spikes — s
spring — ^
heart — h
exit — e Note: when using exit it takes up a square of 9 objects referenced from the top left so make sure there is nothing 3 objects to the right and down

Note Trevor starts at around object 3 across 4 down ish

MOST IMPORTANTLY ENJOY >> for more trevorness visit my site www.breakingwave.co.nr