fb:porticula NoPaste
pong
Uploader: | Manello |
Datum/Zeit: | 12.02.2014 20:55:44 |
DIM SHARED AS ANY PTR sprite
DIM SHARED AS INTEGER x1,y1,x2,y2,x12,y12,x22,y22,ende=0
DIM AS STRING datei="player.bmp"
DIM SHARED AS ANY PTR anzeige
anzeige=MUTEXCREATE
x1=100
y1=350
x2=120
y2=205
x12=680
y12=350
x22=700
y22=205
SCREENRES 800,800,32
sprite=IMAGECREATE(20,145)
LINE STEP (400,0)-(400,800),RGB(255,255,255),,&hFF00
BLOAD datei,sprite
PUT (x1,y1),sprite,PSET
PUT (x12,y12),sprite,PSET
SUB player1 (BYVAL sprite AS ANY PTR,BYVAL x1 AS INTEGER,BYVAL y1 AS INTEGER, _
BYVAL x2 AS INTEGER,BYVAL y2 AS INTEGER,BYVAL datei AS STRING,BYVAL ende AS INTEGER)
DO
main:
IF MULTIKEY(17) THEN 'L hoch
IF y1=110 THEN
GOTO main
ELSE
MUTEXLOCK anzeige
PUT (x1,y1),sprite,XOR
y1=y1-1
y2=y2-1
PUT (x1,y1),sprite,XOR
MUTEXUNLOCK anzeige
SLEEP(1)
END IF
ELSEIF MULTIKEY(31) THEN 'L runter
IF y2=690 THEN
GOTO main
ELSE
MUTEXLOCK anzeige
PUT (x1,y1),sprite,XOR
y1=y1+1
y2=y2+1
PUT (x1,y1),sprite,XOR
MUTEXUNLOCK anzeige
SLEEP(1)
END IF
END IF
LOOP UNTIL MULTIKEY(1) OR ende=1
END SUB
SUB player2 (BYVAL sprite AS ANY PTR,BYVAL x12 AS INTEGER,BYVAL y12 AS INTEGER, _
BYVAL x22 AS INTEGER,BYVAL y22 AS INTEGER,BYVAL datei AS STRING,BYVAL ende AS INTEGER)
DO
main2:
IF MULTIKEY(72) THEN 'R hoch
IF y12=110 THEN
GOTO main2
ELSE
MUTEXLOCK anzeige
PUT (x12,y12),sprite,XOR
y12=y12-1
y22=y22-1
PUT (x12,y12),sprite,XOR
MUTEXUNLOCK anzeige
SLEEP(1)
END IF
ELSEIF MULTIKEY(80) THEN 'R runter
IF y12=690 THEN
GOTO main2
ELSE
MUTEXLOCK anzeige
PUT (x12,y12),sprite,XOR
y12=y12+1
y22=y22+1
PUT (x12,y12),sprite,XOR
MUTEXUNLOCK anzeige
SLEEP(1)
END IF
SLEEP(1)
END IF
LOOP UNTIL MULTIKEY(1) OR ende=1
END SUB
DIM AS ANY PTR thread1=THREADCREATE(CAST(ANY PTR,@player1))
DIM AS ANY PTR thread2=THREADCREATE(CAST(ANY PTR,@player2))
DO
SLEEP(0.1)
LOOP UNTIL MULTIKEY(1)
ende=1
MUTEXDESTROY anzeige
THREADWAIT thread1
THREADWAIT thread2
IMAGEDESTROY sprite