
-----------------------------------
Shadow456732
Tue Dec 18, 2012 7:48 pm

Input.KeyDown Problems... Seems to keep the value of the key until something happens...
-----------------------------------
What is it you are trying to achieve?
This program is essentially like one of those asteroid dodge programs. You are the ball, avoid all in coming objects. Though, the problem is, that when you lose, the game ends.
I want to make it so clicking enter will bring you back to the main menu. And then you click enter once more to start the game. 


What is the problem you are having?
When i click enter in the end to restart the loop, it seems to start where the game starts... So it dosen't show the intructions, and it dosen't wait for the input. 


Describe what you have tried to solve this problem
Tried putting delay's in a few places to see wether or not it actually did go through that code. It seemed to, but it would assume that enter was clicked when it wasn't. 


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)





setscreen ("graphics:500;700")
View.Set ("nobuttonbar")
View.Set ("offscreenonly")
var jumpheight, flor, radius, endcolor, score, button, mx, my, font : int
var x, y, xpixelchange, ypixelchange, distance : real
var jump, buffer, fall, endgame : boolean
var left, right, up, down : char
var key : array char of boolean
var asteroid, aradius, acolor : array 1 .. 100 of int
var aspeed, ax, ay : array 1 .. 100 of real
var num : int

loop
font := Font.New ("serif:12")
num := 10
flor := 100
jumpheight := flor + 150
radius := 15
x := (maxx / 2)
y := flor + radius
xpixelchange := 0.5
ypixelchange := 0.6
left := 'a'
right := 'd'
up := (chr (ORD_SPACE))
down := 's'
buffer := true
jump := false
fall := false
endgame := false
score := 0
endgame := false
for i : 1 .. num
    ax (i) := Rand.Int (0, maxx)
    aradius (i) := Rand.Int (15, 20)
    aspeed (i) := Rand.Int (2, 9) / 10
    ay (i) := maxy + aradius (i)
    acolor (i) := Rand.Int (0, 244)
end for
Draw.FillBox(1,1,10,10,black)
Font.Draw ("- Welcome to balloon dodge! Your Objective Is To Dodge Oncoming Ballons!", 1, round (maxy / 2), font, red)
Font.Draw ("- Use A and D to move left and right. Spacebar is to jump", 1, round (maxy / 2) - 15, font, red)
Font.Draw ("- Click p to pause the game ,click any keyboard key to resume", 1, round (maxy / 2) - 30, font, red)
Font.Draw ("- Hit The Enter Key To Begin!", 1, round (maxy / 2) - 45, font, red)
View.Update
loop
    Input.KeyDown (key)
    if key (KEY_ENTER) then
        exit
    else
        buffer := true
        end if
end loop

loop
    cls
    Draw.FillBox (0, flor, maxx, maxy, gray)
    Draw.FillBox (0, 0, maxx, flor, green)
    Draw.FillBox (0, flor - 10, maxx, flor, red)
    Input.KeyDown (key)
    if key (left) and x >= radius then
        x := x - xpixelchange
    elsif key (right) and x = jumpheight then
            jump := false
            fall := true
        end if
    elsif fall = true and y >= flor + radius then
        y := y - ypixelchange
        if y 