Tutorial | Blitz Basic
For this tutorial, I am using (Windows only, but runs perfectly on Linux/Wine).
; Keep ball on screen (Boundaries) If x < 0 Then x = 0 If x > 768 Then x = 768 If y < 0 Then y = 0 If y > 568 Then y = 568
; Clear movement dx = 0 dy = 0 ; Read arrows If KeyDown(203) Then dx = -5 ; Left Arrow If KeyDown(205) Then dx = 5 ; Right Arrow If KeyDown(200) Then dy = -5 ; Up Arrow If KeyDown(208) Then dy = 5 ; Down Arrow
; Slow down the loop so it doesn't zoom too fast (50 milliseconds) Delay 20 Wend blitz basic tutorial
; 5. Scoring (Reset ball) If ball_x < 0 Then p2_score = p2_score + 1 ball_x = 400 ball_y = 300 ball_dx = -ball_dx Delay 1000 EndIf
If ball_x > 800 Then p1_score = p1_score + 1 ball_x = 400 ball_y = 300 ball_dx = -ball_dx Delay 1000 EndIf
; --- Game logic goes here --- Text 10, 10, "Press Escape to quit" For this tutorial, I am using (Windows only,
; 1. Input (W/S for Left, Up/Down for Right) If KeyDown(17) Then p1_y = p1_y - 5 ; W If KeyDown(31) Then p1_y = p1_y + 5 ; S If KeyDown(200) Then p2_y = p2_y - 5 ; Up If KeyDown(208) Then p2_y = p2_y + 5 ; Down
In this tutorial, we are going to ignore classes, pointers, and memory management. We are going to open a window, draw a bouncing ball, and make a beep noise. Let’s get nostalgic. First, you need the compiler. Since BlitzBasic is abandonware (but beloved), head to the official archive at blitzbasic.com (or GitHub for BlitzMax NG).
; Draw the ball (Oval x, y, width, height, solid) Color 255, 0, 0 ; Set color to Red (R,G,B) Oval x, y, 32, 32, True Input (W/S for Left, Up/Down for Right) If
For p.Player = Each Player ; Draw or update p Next Let's tie it all together into a 2-player Pong game. No AI, just two paddles and a ball.
Let’s modify our ball to move via the .
While Not KeyHit(1)