yeah i know, just another pong without media, but i was bored:p
Rem Project: Pong
Rem Created: 13.04.2006 16:49:51
Rem ***** Main Source File *****
level# = 0.2 `level of how tough the ai is
`0.2 is very dumb, 1.0 is very clever (never loses actually)
null = make vector2(1)
top:
REM CREATE IMAGES
REM STICK
box 0,0,10,50
get image 1,0,0,10,50
cls
sprite 1,0,0,1
offset sprite 1, sprite width(1)/2.0, sprite height(1)/2.0
sprite 1,5,25,1
sprite 3,635,25,1
REM BALL
Circle 10,10,9
get image 2,0,0,20,20
cls
sprite 2,0,0,2
offset sprite 2, sprite width(2)/2.0, sprite height(2)/2.0
sprite 2,320,240,2
backdrop on
reRandom:
nx# = rnd(8)-4 : ny# = rnd(8)-4
if nx# = 0 then goto reRandom
if ny# = 0 then goto reRandom
set vector2 1,nx#, ny# : normalize vector2 1, 1
nx# = x vector2(1) : ny# = y vector2(1)
bx# = 0 : by# = 0
Sync On
Do
y = y + downkey() - upkey()
if y < 25 then y = 25
if y > screen height() - 25 then y = screen height() - 25
sprite 1,5,y,1
if sprite hit (2,1) then nx# = nx#*-1
if sprite hit (2,3) then nx# = nx#*-1
if sprite x(2) < 10 or sprite x(2) > 630 then sprX = sprite x(2) : exit
if sprite y(2) < 10 then ny# = ny#*-1
if sprite y(2) > 470 then ny# = ny#*-1
bx# = (bx# + nx#) : by# = (by# + ny#)
sprite 2, 320+bx#, 240+by#, 2
if sprite collision (2,1)
endif
ay# = ay# + ai#
if ay# < by# then ai# = level#
if ay# > by# then ai# = -level#
sprite 3,630,240+ay#,1
Line 320, 0, 320, 640
text 300, 0, str$(score1)
text 340, 0, str$(score2)
Sync
Loop
if sprX < 10 then score2 = score2+1
if sprX > 630 then score1 = score1+1
delete image 1 : delete image 2
delete sprite 1 : delete sprite 2 : delete sprite 3
goto top
Too Sexy