hi, i decided to try a simple game that turned out to be a headache
firstly my collisions with the bricks dont work and secondly the deflection when colliding with another sprite is all wrong
also how do you define a global variable without using dim statement.
how could such a basic game be so hard to make
plz help me obi wan kenobi, your my only hope
rem resolution 800 x 600
mousepx = 400 : mousepy = 580 : oldxsprite = 0 : oldysprite = 0
load image "e:spritesbrick.png",1
load image "e:spritesball.png",2
load image "e:spritesbat.png",3
load image "e:spritesleft_wall.png",4
load image "e:spritesright_wall.png",5
load image "e:spritesback_wall.png",6
ink rgb(250,250,250),0
sync on
position mouse 400,580
rem hide mouse
direction = 0 : angle = 0 : impact = 0 : direction = 0
newxsprite = 0 : newysprite = 0
cls
rem display the whole game screen
sprite 32,400,300,2
sprite 33,400,580,3
sprite 34,0,0,4
sprite 35,790,0,5
sprite 36,11,0,6
rem display and assign brick sprites
for t = 1 to 10
sprite t,t*67,35,1
sprite t+10,t*67,70,1
sprite t+20,t*67,105,1
next t
rem object sprite no. image no.
rem brick = sprite 31 = 1
rem ball = sprite 32 = 2
rem bat = sprite 33 = 3
rem left wall = sprite 34 = 4
rem right wall = sprite 35 = 5
rem back wall = sprite 36 = 6
gosub serve_ball
rem ==================================================
do
oldxsprite = sprite x(32)
oldysprite = sprite y(32)
set cursor 5,7
impact = sprite hit(32,0)
print "x = ";oldxsprite;" y = ";oldysprite;" angle = ";angle;" impact = ";impact
mousepx = mousex() : mousepy = mousey()
if mousepx > 760 then mousepx = 760
rem destroy brick when hit
if impact > 0 and impact < 31 then gosub deflection_angle
if impact > 0 and impact < 31 then delete sprite impact
rem change angle when hit bat
if impact = 33 then gosub deflection_angle
rem change angle when hits walls
if impact = 34 then gosub deflection_angle
if impact = 35 then gosub deflection_angle
if impact = 36 then gosub deflection_angle
rem calculate new co-ordinate
newxsprite = newxvalue(oldxsprite,angle,2)
newysprite = newyvalue(oldysprite,angle,2)
wait 20
rem move sprite to new co-ordinate
sprite 32,newxsprite,newysprite,2
rem move bat with mouse x direction
sprite 33,mousepx ,580,1
sync
if escapekey() = 1 then end
loop
rem subroutine section
rem ===============================================
rem serve ball
serve_ball:
direction = rnd(3)
if direction = 1 then angle = 45
if direction = 2 then angle = 315
if direction = 0 then angle = 45
if direction = 3 then angle = 45
sprite 32,400,300,2
return
rem workout deflection angle
deflection_angle:
if angle = 45 then angle = 315
if angle = 225 then angle = 135
if angle = 135 then angle = 225
if angle = 315 then angle = 45
if angle = 0 then angle = 180
if angle = 180 then angle = 0
if angle = 270 then angle = 90
if angle = 90 then angle = 270
return
managed to figure out the snippet and file transfer
thanks