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

Username:   Password: 
 RegisterRegister   
 My jumpy game problem
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
slender0123




PostPosted: Fri Sep 13, 2013 5:28 pm   Post subject: My jumpy game problem

Im trying to get it so when the ball drops, you get a choice to retry or not but, for some reason, the put statements ABOVE the get try statement are not appearing until i put the get statement...

the code so far.. its a very small teleporter game, its wierd, i know lol.

code:

var keys : array char of boolean %my variables and constants
var x, y, y2 := 25
var x2 := 125
var X, Y := 100
var y_velocity := 0
const gravity := 2
var bounce := 0
var try : string
setscreen ("graphics, offscreenonly")
procedure game
loop
Input.KeyDown (keys) %Line movements
  if keys (KEY_RIGHT_ARROW) then
    x2 += 15
    x += 15
  end if
  if keys (KEY_LEFT_ARROW) then
    x2 -= 15
    x -= 15
  end if

          y_velocity -= gravity  %Ball gravity effect
    Y += y_velocity 

    if Y = 0 then     % ball hitting 0
    put "You got ", bounce, " bounces before you let the ball drop!" %Broken restart
    put "Try again? (y, n)"
    get try
    if try = "y" then
    game
    else
    exit
    end if
    end if

if Math.DistancePointLine (X,Y,x,y,x2,y2) < 15 then %Ball bounce
y_velocity := 35
x := x + 10
X := Rand.Int(1, 500)
bounce := bounce + 1
end if
 
 
 
drawline (x,y,x2,y2, black) %Objects and end loop
Draw.FillOval(X, Y, 15,15, brightgreen )
View.Update
delay (1)
cls
end loop
end game
game


I might later make it so the ball changes color when it bounces, i dont know if thats easy or not..
Sponsor
Sponsor
Sponsor
sponsor
Dreadnought




PostPosted: Fri Sep 13, 2013 6:22 pm   Post subject: Re: My jumpy game problem

View.Update
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  [ 2 Posts ]
Jump to:   


Style:  
Search: