
-----------------------------------
GabeC99
Thu Jan 15, 2015 9:11 am

Can't get a ball to bounce off four sides
-----------------------------------
so basically I need a ball to bounce off four walls in my program and i can make it bounce off one but I cant get it to do it for the other 3.
If i try to edit a new code to make it bounce off the second wall it just edits my code for the first wall bounce. Please help!

[code]
setscreen ("graphics: 200, 500")

var centerX, centerY : int

centerX := 30
centerY := 100


loop
    drawoval (centerX, centerY, 25, 25, 1)
    drawfill (centerX, centerY, 7, 1)

    delay (10)
    cls


    if centerX < 200 - 25 then
        centerX := centerX + 1
        centerY := centerY + 1
    end if

    if centerX = 200 - 25 then
        loop
            centerX := centerX - 1
            centerY := centerY + 1
            drawoval (centerX, centerY, 25, 25, 1)
            drawfill (centerX, centerY, 7, 1)

            delay (10)
            cls
        end loop
    end if

    if centerX = 30 - 400 then
    centerX := centerX + 1
    centerY := centerY + 1
    drawoval (centerX, centerY, 25, 25, 1)
            drawfill (centerX, centerY, 7, 1)
            
            delay (50)
        end if    cls
end loop
[/code]

-----------------------------------
Tony
Thu Jan 15, 2015 2:04 pm

RE:Can\'t get a ball to bounce off four sides
-----------------------------------
From your code
[code]
    if centerX = 200 - 25 then 
        loop 
            centerX := centerX - 1 
            centerY := centerY + 1 
            drawoval (centerX, centerY, 25, 25, 1) 
            drawfill (centerX, centerY, 7, 1) 

            delay (10) 
            cls 
        end loop 
    end if 
[/code]
when does this loop exit?

-----------------------------------
GabeC99
Fri Jan 16, 2015 10:07 am

Re: RE:Can\'t get a ball to bounce off four sides
-----------------------------------
From your code


It doesnt

-----------------------------------
Insectoid
Fri Jan 16, 2015 1:46 pm

RE:Can\'t get a ball to bounce off four sides
-----------------------------------
That's right! So when does the rest of the code execute?
