
-----------------------------------
ceraf
Tue Oct 26, 2004 9:44 pm

car racing game with moving background
-----------------------------------
I made a 2-player car racing game using only circuit tracks (due to image resolution limit).  Since I want to add larger tracks, the only way to accomodate it is to use the moving background method.

I've already tried taking some code from the Space Game, but it was a complete failure.  Anyone know how to do this?

-----------------------------------
Delos
Wed Oct 27, 2004 10:16 am


-----------------------------------
Larger maps?  You might want to look into View.UpdateArea().  I'm not sure if this answers your question though.

View.UpdateArea() will only refresh a bit of the screen, so speed the programme up if you know exactly which areas need updating and which don't.  Generally, this allows for the use of larger images w/ anim.

-----------------------------------
ceraf
Wed Oct 27, 2004 12:08 pm


-----------------------------------
View.UpdateArea()?  I can't seem to find that command.  What version of Turing is it?  I am using 4.0.4c.

For those who don't want to bother downloading a zip file, here's the code:


just download the zip file -- Tony


-----------------------------------
wtd
Wed Oct 27, 2004 2:27 pm


-----------------------------------
A few thoughts.

Use meaningful variable names.  What does "carslo" mean?  If I don't know, how can I help you with your code?
Learn about records.  There are tutorials here.  You can use them to dramatically cut down the number of variables you have hanging around.

type Vector : record
   x, y : int
end record

type Car : record
   acceleration : int
   speed : Vector
   location : Vector
   % ...
end record

var cars : array (1 .. n) of Car
cars(1).acceleration := 2
cars(1).speed.x := 5
cars(1).speed.y := 2

Use procedures and functions not just to handle the graphics of the program, but also to handle the logic of the program as well.

For instance:

procedure moveCarUp(var c : Car, n : int)
   c.location.y += n
end moveCarUp


-----------------------------------
Tony
Wed Oct 27, 2004 2:28 pm


-----------------------------------
What version of Turing is it?  I am using 4.0.4c.
Time to upgrade yourself to 4.0.5 :wink:

-----------------------------------
ceraf
Wed Oct 27, 2004 5:39 pm


-----------------------------------
Use meaningful variable names. What does "carslo" mean? If I don't know, how can I help you with your code? 
Sorry about that.  I haven't developed the habit of writing in sudocode to explain things.  I'm also very bad at giving variable names.

The car position are x and y, and the second car position are x1 and y1.  To my knowledge, those are the only variables that are necessary for moving a background, unless you need to add more for the map position too. (Btw, "carslo" is how quick the car decelerates or slows down.) 

Learn about records. There are tutorials here. You can use them to dramatically cut down the number of variables you have hanging around. 
Use procedures and functions not just to handle the graphics of the program, but also to handle the logic of the program as well. 
Wow...those are really useful.  Too bad I only have a limited amount of knowledge on Turing.  And now I'm starting to learn VB in class, and I'll get really confused.

Time to upgrade yourself to 4.0.5
Only if i could.  The way my school computers work, you can't update anything.  Only administrators can.  :(

-----------------------------------
wtd
Wed Oct 27, 2004 8:32 pm


-----------------------------------
Learn about records. There are tutorials here. You can use them to dramatically cut down the number of variables you have hanging around. 
Use procedures and functions not just to handle the graphics of the program, but also to handle the logic of the program as well. 
Wow...those are really useful.  Too bad I only have a limited amount of knowledge on Turing.  And now I'm starting to learn VB in class, and I'll get really confused.

I wouldn't worry about it too much.  The concepts will serve you very well in almost any programming language you learn, and Turing is relatively easy to learn them in, compared to some languages.

You have to learn them sometime.  Better to learn them now than to continue doing things in a "wrong" way and then have to unlearn those wrong ways.  :)
