
-----------------------------------
1337.Billy
Wed Jun 08, 2005 6:49 pm

Box movement help
-----------------------------------
Hey everyone, I beleive this is my first post so Hi. Im working on my final project for computer class. Im making a paddle ball game. I need help moving the box, and im not sure how to make it move

My code do far:

%Abilio Rebelo-Soares
%Final CPT
%June 3rd, 2005
import GUI in "%oot/lib/GUI"
var font : int := Font.New ("Arial:40")
var title : string := "Abilio's Pong!"
var username : string
procedure nextscreen
    var quitButton : int
    GUI.Quit
    cls
end nextscreen
var button : int := GUI.CreateButton (250, 200, 120, "PLAY!", nextscreen)
Font.Draw (title, 150, 250, font, 12)
loop
    exit when GUI.ProcessEvent
end loop
put "Before you start playing what is your name?"
get username : *
cls
var x, y : int
x := 100
y := 100
var chars : array char of boolean
loop
    Input.KeyDown (chars)
    if chars (KEY_RIGHT_ARROW) then
        x := x + 10
    end if
    if chars (KEY_LEFT_ARROW) then
        x := x - 10
    end if
    drawfillbox (x,y , 4, 4, red)
    delay(25)
    cls
end loop


Thanks in advance whoever helps me

-----------------------------------
vagyb
Wed Jun 08, 2005 9:10 pm


-----------------------------------
well u are moving only the X2 coordinate, u have to move both the x1 and x2 coordiantes (when u draw the box). and cls too

-----------------------------------
1337.Billy
Thu Jun 09, 2005 2:34 pm


-----------------------------------
Thanks for helping i was able to make the paddle move but now im not sure how to get a ball in there and make it hit the sides and bounce and such. I have looked at the collision detection tutorials but have not been successful, so can someone please help. My new code is below:

import GUI in "%oot/lib/GUI"
colorback(black)
cls
color(white)
var font : int := Font.New ("Arial:40")
var title : string := "Abilio's Paddle Ball!"
var username : string
var score: int:=0
var chars : array char of boolean
var pos := maxx div 2
var ballx := maxx div 2
var bally := 15 
procedure nextscreen
    var quitButton : int
    GUI.Quit
    cls
end nextscreen
var button : int := GUI.CreateButton (255, 200, 150, "PLAY!", nextscreen)
Font.Draw (title, 100, 250, font, 12)
loop
    exit when GUI.ProcessEvent
end loop
put "Before you start playing what is your name?"
get username : *
locate (3, 1)put "Game starting in..."
delay (1000)
locate (4, 1)put "3"
delay (1000)
locate (5, 1)put "2"
delay (1000)
locate (6, 1)put "1"
delay (1000)
locate (7, 1)put "GO!"
delay (1000)
cls
setscreen ("offscreenonly")
loop
drawfillbox (pos - 25, 15, pos + 25, 20, brightred)
Input.KeyDown (chars)
if chars (KEY_LEFT_ARROW) and pos - 25 > 0 then
    pos -= 1
    ballx -= 1
elsif chars (KEY_RIGHT_ARROW) and pos + 30 < maxx then
    pos += 1
    ballx += 1
end if
View.Update
cls
locate (1,1) put "Name:", username
locate (1,35) put "Score:", score
end loop
Thanks to who helps me

-----------------------------------
1337.Billy
Thu Jun 09, 2005 8:39 pm


-----------------------------------
Anyone, please I really need help on this one part.

-----------------------------------
MysticVegeta
Thu Jun 09, 2005 8:44 pm


-----------------------------------
Press F10 -> Music.PlayFile -> Look at example number 2. You will see they have a star bouncing off the edges. I cant tell you anything more because i haven;t taken Grade 10 math trignometry. (cos, tan, sin)

-----------------------------------
vagyb
Thu Jun 09, 2005 8:49 pm


-----------------------------------
well easiest thing for u would be to use whatdotcolor

so first get a picture of ur ball, import it in turing, give X and Y variables, give Height and Width variables to it. then use whatdotcolor

so for example
if whatdotcolor (x, y) = red then
put code here for w/e direction u want to go.

to make the bounce angle the same as real life is very hard, so i'm guessing u should just do a 45 degree angle bounce off.

-----------------------------------
1337.Billy
Thu Jun 09, 2005 8:55 pm


-----------------------------------
Well, Im just drawing a circle but i want it to bounce of any where in the screen and off the paddle and somehow get a counter to keep track of their score, Im not trying to make anyone giving me source code just some help on these parts.

-----------------------------------
Cervantes
Fri Jun 10, 2005 3:20 pm


-----------------------------------
Assuming you've got x and y coordinates of the ball that correspond to the centre of the ball:

if ball.x + ball.radius >= maxx or ball.x - ball.radius 