Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
I need help with a drag racing game
Author Message
dark_knight_97

Posted: Thu Sep 19, 2002 2:55 pm   Post subject: I need help with a drag racing game

Tony sent me here from the turing tutor site. Heres the deal, i need to know how to make my sprites move across the screen which i have done, now i need to make my rpm gauge, speed and anything else i want to have, move at the same time, but at different ratios. At the same time as that i need my car to move,(btw this is a sideveiw race if that helps any). I also need the wheels which are detached sprites from the car to move and spin at the same and different ratios. I also need to figure out if i am reving the engin how to make it come back down. Any fixes to these problems would be great thanks.

Tony

Posted: Thu Sep 19, 2002 3:57 pm   Post subject: (No subject)

Welcome to the SWAT, enjoy your stay.

Now then, to move the sprite you just need to change its X and Y coordinates
 code: Sprite.SetPosition (spriteID, x, y : int, centered : boolean)

The good thing about sprites is that you don't have to redraw them and they don't flash like Pic.Draw

Now about moving things at same time. There are 2 ways to do so:

process
fork allows to run 2 or more procedures at the very same time, but the drawback is that the order of execution of procedures is unpredictable. They tend to run about evenly, but sertain procedures might get ahead of others, especially if theres more then 2 running.

 code: var car1, car2:int car1 := 0 car2 := 0 process move1 loop car1 := car1 + 1 locate(1,1) put "car 1 : ", car1 end loop end move1 process move2 loop car2 := car2 + 1 locate(2,1) put "car 2 : ", car2 end loop end move2 fork move1 fork move2

Code above would show how processes work. At sertain points 1 car was ahead of the other by over 5 points, so you should keep that in mind.

Note: fork processName is used to call the process and execute it as same time as other code.

Second way - loops with ratio multiplier
Basically what this does is that you run your loops with single counter, but for each value you need to change, you change it by the counter multiplied by the specific ratio of that object to the counter. For example:
 code: for i:1..25 locate(1,1) put "object 1 :", i*2 put "object 2 :", i*3 delay(100) end for

About spinning wheels - winoot 4.0.1[p] has a Pic.Rotate feature, but unfortunatly it doesn't support sprites. So its ether sprites or rotating regulat bmp/jpeg images.

What you can do now is to draw another image of the wheel in different position and change sprites when you want to rotate the wheel.

 code: Sprite.Animate (spriteID, picID, x, y : int, centered : boolean)

Where spriteID is the variable. picID is the id of the new picture it want your image change to. X and Y are new coordinates and cenetered is ether true or false.

I hope this helped you out. If you got any future questions, let us know.
Tony's programming blog. DWITE - a programming contest.
dark_knight_97

Posted: Thu Sep 19, 2002 5:52 pm   Post subject: Thanks for the help Tony

Just saying thanks for the help u guys.. i'll probly be back with more questions. Thanks!
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 3 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: