Tutorial 3: The "OneButton" game application

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Tutorial 3: The "OneButton" game application

Post by VilleK »

The third tutorial is online now:

Tutorial 3: The "OneButton" game application.

It is a tutorial that will guide you through making a little game. Note that if you plan to follow the tutorial you will need the latest 0.92 beta of ZGameEditor.

Please check it out, and help report any errors or omissions in the tutorial.
nmarshall
Posts: 14
Joined: Wed Mar 14, 2007 11:59 pm
Location: Los Angeles, California

Post by nmarshall »

Hi I just went through the tutorials and I think overall they are very good and easy to follow. I'll just comment on tutorial 3 here.

When creating the PlayerModel you set CollisionBounds = 0.5 0.5 but there are four fields and you don't explain what each field is.

When you add the KeyPress Keys = ^{ you should say that ^ checks for the up arrow and { checks for the left mouse button. Also I noticed that the up arrow doesn't work when playing in the preview window.

When you explain why you use App.DeltaTime with Velocity the units of Velocity get confused. I'm wondering, wouldn't you normally want your Velocity independant of your framerate? It seems like it would be simpler for the game designer if we didn't have to worry about DeltaTime for Velocity or maybe you could have a VelocityAbsolute that would not depend on the frame rate.

In one line you set
CurrentModel.Velocity.Y-=5.5*App.DeltaTime;
Velocity(distance/frame) -= 5.5(distance/s) * App.DeltaTime(s/frame)
which suggests that the units for Velocity is distance/frame. But, in the next line you clamp it with
CurrentModel.Velocity.Y=clamp(CurrentModel.Velocity.Y,-6,5);
and the values -6 and 5 would also be in units of distance/frame so your visible clamping velocities change with your framerate.

To clamp the visible velocity you would need to do something like
CurrentModel.Velocity.Y = clamp(CurrentModel.Velocity.Y,(-600*App.DeltaTime),(500*App.DeltaTime));
(Assuming your average framerate is about 100fps) that way the clamping velocities are not dependant on your framerate.
The same problem appears where you clamp the velocity of the moving walls.

For me, it seems like having to use DeltaTime with every Velocity is more complicated than necessary.
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Thank you for all this feedback! I really want the tutorials to be easy to understand.
nmarshall wrote:When creating the PlayerModel you set CollisionBounds = 0.5 0.5 but there are four fields and you don't explain what each field is.
I just added this:

"Notice that CollisionBounds have four edit fields, but we only set the first two. This is because currently the only supported collision style in ZGameEditor is 2D rectangular collision. The first value is width and the second is height. Later versions of ZGameEditor may support other collision styles, so the upper two values of CollisionBounds are reserved for future use."
When you add the KeyPress Keys = ^{ you should say that ^ checks for the up arrow and { checks for the left mouse button. Also I noticed that the up arrow doesn't work when playing in the preview window.
Ok, text updated. I will check why arrow keys do not work in preview window.

Regarding DeltaTime:

The unit of Model.Velocity is the amount that the model will move in one second. This unit is frame-rate independent.

When velocity is updated relative to its current value (+= or -=) the value that we add or subtract (the acceleration) must be multiplied with deltatime.

Example:
Velocity.X = 5; //no deltatime needed here
Velocity.X += 5 * App.DeltaTime; //calculate acceleration, deltatime is needed

A solution to avoiding deltatime when updating velocities would be to introduce a new model property "Acceleration", which would represent a frame rate independent value of the change to velocity. This is probably a good idea, and I will examine this for a later version.

Thanks again.
nmarshall
Posts: 14
Joined: Wed Mar 14, 2007 11:59 pm
Location: Los Angeles, California

Post by nmarshall »

Ah, Ok!

Sorry, for some reason my mind wasn't thinking that the -= operation was happening between every frame so it would happen 100 times a second at 100fps and 10 times a second at 10fps. That makes sense now.
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

arrows not working,. Space may b a better option.. ?

Post by jph_wacheski »

yes, I too just got through this tutorial, and I was stuck by the fact that the arrows don't work in the preivew window! ( I thought not at all, till i read this thread and checked it! ) perhaps a little note in the tutorial text until the bug is crushed! thanks.

Good tutorial here,. I learned a bunch about how you have have implemented your system,. and now I feel ready to create something new of my own design,. . I will post it as soon as it is fun to play,. ;)

peace.
iterationGAMES.com
Post Reply