Eyz,
When I was a totall newby (probebly still are
) I started with a little game pong
I codes from others and I had a look at the one player pong code [b]) Then I started. Just take the headlines witch you see in every 2D game. Use sprites to make the blocks. Again, the manual is your friend
Here's my code of my first and only 2D game pong
cls
hide mouse:
sync on:
sync rate 60:
do
repeat
cls rgb(100,100,100):
ink rgb(255,255,255),1:
print "choose level between 1 and 10":
input levelline#:
until levelline# => 1 and levelline# =< 10:
levelline#=levelline#*2:
ink rgb(000,255,000),2:
box 0,0,15,100:
get image 1,0,0,15,100:
ink rgb(255,000,000),3:
box 0,0,15,100:
get image 2,0,0,15,100:
ink rgb(255,255,255),4:
cls
print FillCircle(8,8,7):
get image 3,0,0,16,16:
cls
ink RGB(255,128,64),5:
print FillCircle(20,20,10):
for x=4 to 14:
get image x,11,11,30,30:
next x:
cls rgb(100,100,100):
for x=4 to 6:
objx=320
objy=0+pos
sprite x,objx,objy,x:
inc pos,100
next x
score=0:
playerx#=10.0:
playery#=240.0:
playerspeed#=0.0:
playermove#=2.0:
player=1:
enemyx#=610.0:
enemyy#=240.0:
enemyspeed#=0.0:
enemymove#=levelline#:
enemy=2:
ballx#=100.0:
bally#=200.0:
ballxspeed#=2.0:
ballyspeed#=2.0:
ballinc#=0.2:
ball=3:
repeat
for x=100 to 101
objy=objy+1+pos
sprite x,320,objy,x
next x
if upkey()=1:
playerspeed#=0.0-playermove#:
else
if downkey()=1:
playerspeed#=playermove#:
else
playerspeed#=0:
endif
endif
if enemyy#+50-oldbally# < 0.0:
enemyspeed#=enemymove#:
endif
if enemyy#+50-oldbally# > 0.0:
enemyspeed#=0.0-enemymove#:
endif
if bally# < 0.0 or bally# > 465.0 then ballyspeed# = 0.0-ballyspeed#:
if oldplayery# < 0.0:
oldplayery#=0.0:
playery#=0.0:
endif
if oldplayery# > 380.0:
oldplayery#=380.0:
playery#=380.0:
endif
if oldenemyy# < 0.0:
oldenemyy#=0.0:
enemyy#=0.0:
endif
if oldenemyy# > 380.0:
oldenemyy#=380.0:
enemyy#=380.0:
endif
playery#=playery#+playerspeed#:
oldplayery#=curvevalue(playery#,oldplayery#,5.0):
enemyy#=enemyy#+enemyspeed#:
oldenemyy#=curvevalue(enemyy#,oldenemyy#,10.0):
ballx#=ballx#+ballxspeed#:
oldballx#=curvevalue(ballx#,oldballx#,5.0):
bally#=bally#+ballyspeed#:
oldbally#=curvevalue(bally#,oldbally#,5.0):
sprite player,playerx#,oldplayery#,player:
sprite enemy,enemyx#,oldenemyy#,enemy:
sprite ball,oldballx#,oldbally#,ball:
if sprite hit(player,ball):
ballxspeed#=0.0+(abs(ballxspeed#)+ballinc#):
random#=(rnd(10)-5)/10.0:
ballyspeed#=ballyspeed# + (playerspeed/2) + random#:
score=score+1:
endif
if sprite hit(enemy,ball):
ballxspeed#=0.0-(abs(ballxspeed#)+ballinc#):
random#=(rnd(10)-5)/10.0:
ballyspeed#=ballyspeed# + (enemyspeed/2) + random#:
endif
for x=4 to 6
if sprite hit(x,ball):
ballxspeed#=0.0-ballxspeed#+ballinc#:
random#=(rnd(10)-5)/10.0:
ballyspeed#=ballyspeed# + random#:
endif
next x
sync
until oldballx# > 640.0 or oldballx# < -15.0:
cls
print "score: ";score:
repeat
sync
until returnkey() or spacekey()
if spacekey()=1 then exit
loop
Function Fillcircle(x,y,r):
overdraw=0:
for ang = 1 to 180:
px = x + sin(360-ang) * r:
py = y + cos(360-ang) * r:
px2 = x + sin(ang) * r:py2 = y + cos(ang) * r:
if point(x,py) <> point(0,0) then inc overdraw:
line px,py,px2,py2:
next ang
endfunction overdraw
If good programmer()=1 then print "Finaly I get to the top
"