Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 car racing game with moving background
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ceraf




PostPosted: Tue Oct 26, 2004 9:44 pm   Post subject: 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?



test.zip
 Description:
Included is the original program (test.t) and my failed attempt at moving backgrounding (test2.t) along with the necessary images of cars, maps, etc.

Download
 Filename:  test.zip
 Filesize:  149.92 KB
 Downloaded:  774 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Wed Oct 27, 2004 10:16 am   Post subject: (No subject)

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




PostPosted: Wed Oct 27, 2004 12:08 pm   Post subject: (No subject)

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:

code:

just download the zip file -- Tony
wtd




PostPosted: Wed Oct 27, 2004 2:27 pm   Post subject: (No subject)

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.

    code:
    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:

    code:
    procedure moveCarUp(var c : Car, n : int)
       c.location.y += n
    end moveCarUp

Tony




PostPosted: Wed Oct 27, 2004 2:28 pm   Post subject: (No subject)

ceraf wrote:
What version of Turing is it? I am using 4.0.4c.

Time to upgrade yourself to 4.0.5 Wink
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
ceraf




PostPosted: Wed Oct 27, 2004 5:39 pm   Post subject: (No subject)

Quote:
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.)

Quote:
Learn about records. There are tutorials here. You can use them to dramatically cut down the number of variables you have hanging around.

Quote:
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.

Quote:
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. Sad
wtd




PostPosted: Wed Oct 27, 2004 8:32 pm   Post subject: (No subject)

ceraf wrote:
Quote:
Learn about records. There are tutorials here. You can use them to dramatically cut down the number of variables you have hanging around.

Quote:
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. Smile
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: