Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


The old QBasic Gorilla game

This topic is 5742 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, which is the best way to generate the random scenarios that the Gorilla game did? And, which is the best way to calculate the path the banana should run? thanks for any tip on those subjects. ------------------------------------ the trooper "You''ll take my life but I''ll take yours too"

Share this post

Link to post
Share on other sites
Random was just using (Rnd * MaxHeight)+StartHeight for buildings (were the widths different to?), and you don''t calculate the path the banana should run, you just apply the physics while it''s in the air (gravity, and wind effects).

Think of it like this... You give it the power and angle, you use this to calculate the banana''s starting velocity (we''ll work easy), lets say we throw it at 45 degree angle, and a velocity of 10 (10 meters per second for scale). So, we now do this...

(Lets setup some variables that we''ll need here).
Dim XVel as single, YVel as single
Dim XPos as single, YPos as single
Dim NewTime as single, LastTime as single, TimePassed as single
Dim Gravity as single, Wind as single

Gravity = 9.8 ''gravity = 9.8 m/s downward!
Wind = 2 ''wind = 2 m/s, but take into account friction!

XVel = cos(45*3.1415/180)*Velocity
YVel = sin(45*3.1415/180)*Velocity

Ok, so we''ve got our seperate velocities in meters per second now. (At this point, using 45, and 10, they would both be 5!).

Now, we move one frame...
''(I think the resolution of Timer is in seconds??
NewTime = Timer
TimePassed = NewTime - LastTime
LastTime = NewTime

XPos = XPos + XVel*TimePassed ''Move based on time!
YPos = YPos + YVel*TimePassed ''Move based on time!
XVel = XVel + Wind*TimePassed / 100.0
''100.0 for a "fake" friction effect, as the wind won''t push the
''banana directly!
YVel = YVel + Gravity * TimePassed

We would then draw our banana at that spot after checking for collision.

Billy - BillyB@mrsnj.com

Share this post

Link to post
Share on other sites
I''ll have to go dig up the source at home (I''m sure I''ve got it somewhere), the buildings where generated with the (Rnd * MaxHeight)+StartHeight Ready4Dis mentioned, and the windows where randomly drawn (ie it went across the face of the building, and for each place where there *could* be a window it would randomly decide to draw a lit up window). Ready4Dis''s code for he banana should work, though if anyone wants the original code for historical reasons it was actually a function of time used. Basically it took the starting position and velocity, plus the time elapsed since the throw, to determine where the banana was. If I can find it this afternoon I''ll post some snippets.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!