Cube/Square Escape game concept
Author |
Message |
isaiahk9
|
Posted: Wed Apr 08, 2009 6:11 pm Post subject: Cube/Square Escape game concept |
|
|
Hey compsci,
One of my friends decided he wants to make a 2D version of "Cube Runner", where the player is a vehicle that needs to dodge swarms of cubes (or squares in his case) that fly at you. This is just a concept question : how could one have waves of cubes constantly crash down on you? He can draw each wave of cubes with random integers and a little bit of math, but he's having trouble fixing the program so that many rows of cubes can come, right after another. Right now, he's trying to make a process for each line, and putting delays between the forks, the poor fool. If anybody can help, ty |
|
|
|
|
|
Sponsor Sponsor
|
|
|
DemonWasp
|
Posted: Wed Apr 08, 2009 6:46 pm Post subject: RE:Cube/Square Escape game concept |
|
|
Revert to the standard game architecture:
Turing: |
View.Set ( "offscreenonly" )
loop
% Update all the game objects. Look for collisions and so forth.
Draw.Cls
% Draw all of the game objects. This should be calling a single function for each in-game object that does a few Draw methods - Draw.FillBox() and Pic.Draw come to mind.
View.Update()
Time.DelaySinceLast ( 10 )
end loop
|
If you just store all of the information for each cube in an object (look up type and record, or class) you can just move each one at the update phase and draw each one at the draw phase. |
|
|
|
|
|
isaiahk9
|
Posted: Wed Apr 08, 2009 7:33 pm Post subject: RE:Cube/Square Escape game concept |
|
|
The guy is pretty fresh to Turing, so I would not recommend him working with objects. Maybe you could check how many lines are on the screen, and when another is needed, you create a new line? |
|
|
|
|
|
Dusk Eagle
|
Posted: Wed Apr 08, 2009 10:31 pm Post subject: Re: Cube/Square Escape game concept |
|
|
If you want to avoid using objects, you could use arrays. The easiest way for someone new to Turing would be to have a maximum number of cubes on screen at a time. Let's say such a number was 3. Since we're trying to keep it simple, we won't declare new types, we'll just simply have a number of arrays from 1.. 3 of int type that represent each cube's position and color. Any time one of those cube's y-position's falls below the bottom of the screen (assuming cubes are falling from top to bottom), a new position for this cube is automatically generated. Here's a bit of the code that could be used to do such a thing: Turing: | loop
for : 1 .. 3
%Box moves
y (i )-= 5
if y (i ) < 0 then %if one box's y-position is below the bottom of the screen
%Assign new values to that box
x (i ) := Rand.Int (0, maxx)
y (i ) := maxy
col (i ) := Rand.Int (1, 248)
end if
%Draw that box to the screen
Draw.Box(x (i ),y (i ),x (i )+ 10,y (i )+ 10,col )
end for
end loop |
Again, this ain't the best solution, but it'll work fine for someone new to programming. |
|
|
|
|
|
isaiahk9
|
Posted: Thu Apr 09, 2009 5:25 am Post subject: RE:Cube/Square Escape game concept |
|
|
ty Dusk Eagle, I guess I'll recommend he does something similar to what you said, but it will have to be changed in a couple ways. |
|
|
|
|
|
|
|