Creation of a running game for turing
Author |
Message |
solarsparten
|
Posted: Thu Jan 19, 2012 1:39 pm Post subject: Creation of a running game for turing |
|
|
What is it you are trying to achieve?
What is the problem you are having?
<The program will generate one of the two I have currently created, and then stop>
Describe what you have tried to solve this problem
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
< %setscreen ("graphics")
var jump : int := 20
var gravity : int := 1
var key : array char of boolean
var x, y : int
var vel : real
var timer : int
var platform : int
var p1x : int
var p2x : int
x := 20
y := 400
p1x := 700
p2x := 700
vel := 0
timer := 50
platform := Rand.Int (1, 2)
View.Set ("offscreenonly")
loop
Input.KeyDown (key )
if key (KEY_UP_ARROW) and y = 50 then
vel := jump
end if
vel - = gravity
y + = round (vel )
if y < 50 then
y := 50
vel := 0
end if
Draw.FillBox (x, y, x + 20, y + 40, blue)
Draw.FillBox (0, 0, maxx, 50, black)
if x >= p1x - 1 and x <= p1x + 100 and y = 100
then
x - = 7
else
x + = 1
end if
if timer <= 50 then
timer + = 1
else
platform := Rand.Int (1, 2)
timer := 0
end if
if platform = 1 then
Draw.FillBox (p1x, 50, p1x + 100, 100, black)
p1x - = 7
if x + 20 >= p1x - 1 and x <= p1x + 100 and y < 100 then
x - = 7
end if
if x >= p1x and x <= p1x + 100 and y < 100 then
y := 100
vel := 0
if key (KEY_UP_ARROW) and y = 100 then
vel := jump
end if
end if
elsif platform = 2 then
Draw.FillBox (p2x, 50, p2x + 50, 150, black)
p2x - = 7
if x + 20 >= p2x - 1 and x <= p2x + 50 and y < 150 then
x - = 7
end if
if x >= p2x and x <= p2x + 50 and y < 150 then
y := 150
vel := 0
if key (KEY_UP_ARROW) and y = 150 then
vel := jump
end if
end if
end if
View.Update
delay (30)
cls
end loop>
|
Please specify what version of Turing you are using
<Answer Here> |
|
|
|
|
|
Sponsor Sponsor
|
|
|
copthesaint
|
Posted: Thu Jan 19, 2012 3:30 pm Post subject: RE:Creation of a running game for turing |
|
|
You will have to explain your problem better then this if you expect to get any help. I dont understand what you are having a problem with. |
|
|
|
|
|
solarsparten
|
Posted: Thu Jan 19, 2012 3:43 pm Post subject: RE:Creation of a running game for turing |
|
|
Im sorry, it glitched out when I posted it, basically I have been making a game ment to run, and get as far as you can on a conveyor belt, with out going off either edge of the screen. Right now im working on getting it to randomly generate platforms and obstacles, there are only two right now. The problem is it will generate an object, but then the object will go across the screen a bit, and dissapear, then another one of a different type will appear and start going across, when this happens it will then dissapear, and the other one continues from where it stopped, and it continues on like this, and after those two dissapear completely it wont generate any more. Can I have a bit of help? |
|
|
|
|
|
copthesaint
|
Posted: Thu Jan 19, 2012 4:29 pm Post subject: RE:Creation of a running game for turing |
|
|
Well the reason why your game is only drawing one of the boxes is because you choose to make it draw only one. after 50 loops from your timer you have set platform to be 1 or 2.
then in your if condition you state if platform is equal to 1 then draw platform1 if platform is equal to 2 then draw platform2. You dont have and option to draw both. you have chosen to make it only one or the other. |
|
|
|
|
|
solarsparten
|
Posted: Thu Jan 19, 2012 5:00 pm Post subject: RE:Creation of a running game for turing |
|
|
Yeah, but I told it if it = platform 1 from the random thing, then to makethat platform move across the screen, but I need to figure out how to make it continously choose one, move it, then to do it again |
|
|
|
|
|
copthesaint
|
Posted: Thu Jan 19, 2012 5:41 pm Post subject: RE:Creation of a running game for turing |
|
|
look at where your code is to draw the box. then you should again look at my previous post. |
|
|
|
|
|
|
|