// -------------- // PONG by Gobo // -------------- dentrypoint 0, _EntryHere timer #GpuSpawn _EntryHere: dcvxpipe 3 dclrscr BGColour dsetwidth 0.001 dcolor Yellow jmp Compare // -------- // MAIN // -------- Compare: // CONTROLS mov eax, port0 cmp eax, 1 je P1Up P1UpBack: mov eax, port1 cmp eax, 1 je P1Down P1DownBack: // BOUNCE cmp #Ball1.x, 0.8 jge BounceX cmp #Ball1.x, -0.8 jle BounceX BounceXBack: cmp #Ball1.y, 1 jge BounceY cmp #Ball1.y, -1 jle BounceY BounceYBack: Move: // UPDATE TIMER timer #Uptime sub #Uptime, #GpuSpawn mul #Uptime, 1000 fint #Uptime div #Uptime, 1000 // MOVE BALL add #Ball1.x, #BallInc.x add #Ball1.y, #BallInc.y Draw: // PADDLES drect P1_P1, P1_P2 drect P2_P1, P2_P2 // BALL dcircle Ball1, 0.03 // TEXT dsetsize 28 dwritefmt TPT, ST dsetsize 13 dwritefmt TPP1, SP1 dexit // END // -------------------- // LABELS (FUNCTIONS) // -------------------- BounceX: cmp #Ball1.x, 0 // LEFT OR RIGHT jge Right // LEFT cmp #Ball1.y, #P1_P1.y jl P1Miss cmp #Ball1.y, #P1_P2.y jg P1Miss jmp DoneCheck Right: add #Fs1, 1 DoneCheck: neg #BallInc.x jmp BounceXBack P1Miss: mov #Ball1.x, 0.8 jmp BounceXBack dexit BounceY: neg #BallInc.y jmp BounceYBack dexit P1Up: cmp #P1_P1.y, -1 jle DontP1Up sub #P1_P1.y, #PaddleSpeed sub #P1_P2.y, #PaddleSpeed DontP1Up: jmp P1UpBack dexit P1Down: cmp #P1_P2.y, 1 jge DontP1Down add #P1_P1.y, #PaddleSpeed add #P1_P2.y, #PaddleSpeed DontP1Down: jmp P1DownBack dexit // ----------- // VARIABLES // ----------- // TIME float GpuSpawn float Uptime // PADDLES vec2f P1_P1, -0.9, -0.2 vec2f P1_P2, -0.85, 0.2 vec2f P2_P1, 0.85, -1 vec2f P2_P2, 0.9, 1 float PaddleSpeed, 0.04 // BALL vec2f Ball1, -0.1, -0.1 vec2f BallInc, 0.03, 0.03 // TEXT string ST, 'PONG, made by Gobo :D' string SP1, 'Score: %f' alloc Fs1 vec2f TPT, -0.95, -0.95 vec2f TPP1, -0.95, -0.6 // COLOURS color BGColour, 0, 0, 0 color Yellow, 255, 255, 0