
-----------------------------------
upthescale
Sat Mar 18, 2006 11:20 pm

Pong Help
-----------------------------------
ok i can make a ball move easily



var x,y:int

x:=200
y:=100

loop
drawfilloval(x,y,20,20,7)
delay(20)
drawfilloval(x,y,20,20,0)
x:=x+2
end loop



what ever..he ball movs but when i do a square, it just extends and gets bigger...how do i make it so the whole square moves and not just get bigger?

-----------------------------------
[Gandalf]
Sat Mar 18, 2006 11:43 pm


-----------------------------------
Use cls to clear the screen every time it is executed.
So here's your current code improved using cls:
var x, y : int
x := 200
y := 100

loop
    cls
    drawfilloval (x, y, 20, 20, 7)
    x += 2 %this is the same as x := x + 2
    delay (20)
end loop

Now, I believe the problem with your box code is that you are mixing up the parameters.  They are:
drawfillbox (x1, y1, x2, y2, Color : int)
As on a Cartesian plane.

Also, indent your code properly in the future.

-----------------------------------
upthescale
Sun Mar 19, 2006 12:17 am


-----------------------------------
ok i got the saqure to move fine down the screen, i wana do it so if the mouse touchs any pixel of the square, the game wil say you lose, shud i use mousewhere? and how cuz the squae is moving

-----------------------------------
Flikerator
Sun Mar 19, 2006 12:37 am


-----------------------------------
Use Mouse.Where, and look up whatdotcolor in the help file. 

exit when whatdotcolor (Mx,My) = boxcolor

or

exit when Mx > ### and Mx < ### and My...

Mx and My are the mouse coordinates.

After the loop have the "You've been pwned"

-----------------------------------
Cervantes
Sun Mar 19, 2006 9:27 am


-----------------------------------
Let's avoid whatdotcolour, shall we? It's a bad approach to collision detection, especially for newbies.

Go with the second approach:

% let mx = mouse x
% let my = my
% let blockx = x value for left side of block
% let blockwidth = width of block
% let blocky = y value for bottom of block
% let blockheight = height of block
if mx >= blockx & mx = blocky & my = 4.05 then, this can be achieved more simply by
Math.Distance(x1, y1, x2, y2) which is the same thing as the distance formula in the cartesian plane:
distance = sqrt ( (y2-y1)^2 + (x2-x1)^2 )

All you need to do is check if the distance is < what ever you want it to be less than :)

-----------------------------------
[Gandalf]
Sun Mar 19, 2006 6:06 pm


-----------------------------------
Ehm...  Why use Math.Distance to check collision on a box?  It's just adding extra complications.
