User Tools

Site Tools


sd:sd-8516_user_s_guide

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sd:sd-8516_user_s_guide [2026/03/27 12:16] appledogsd:sd-8516_user_s_guide [2026/04/02 07:13] (current) appledog
Line 116: Line 116:
  
 === PRINT === PRINT
-**Getting Started – The PRINT Command**+**Getting Started -- The PRINT Command**
  
 The easiest way to make your SD-8516 say hello is with **PRINT**. You can also use the ? key as shorthand. The easiest way to make your SD-8516 say hello is with **PRINT**. You can also use the ? key as shorthand.
Line 139: Line 139:
  
 === GOTO === GOTO
-**Your First Program – The Never-Ending Message**+**Your First Program -- The Never-Ending Message**
  
 Let's write a real program. Type **NEW** and press ENTER to clear any old stuff. Let's write a real program. Type **NEW** and press ENTER to clear any old stuff.
Line 596: Line 596:
 | 1986 | WYSE WY-60             | 10 (USER) | 12 | 4 | | 1986 | WYSE WY-60             | 10 (USER) | 12 | 4 |
  
-=== Advanced Looping+=== More Loops
 Stellar BASIC V1 keeps things simple and fast; Originally there was not even a FOR-NEXT loop, and even now there is no WHILE or DO loop. But you can still create powerful repeating loops using just IF...THEN and GOTO. This section will demonstrate the kind of clever thinking you will need to write advanced programs in TinyBASIC. Stellar BASIC V1 keeps things simple and fast; Originally there was not even a FOR-NEXT loop, and even now there is no WHILE or DO loop. But you can still create powerful repeating loops using just IF...THEN and GOTO. This section will demonstrate the kind of clever thinking you will need to write advanced programs in TinyBASIC.
  
Line 631: Line 631:
 10 INPUT "ENTER A POSITIVE NUMBER ", N 10 INPUT "ENTER A POSITIVE NUMBER ", N
 20 IF N > 0 THEN GOTO 40 20 IF N > 0 THEN GOTO 40
-30 PRINT "TRY AGAIN – MUST BE POSITIVE!"+30 PRINT "TRY AGAIN -- MUST BE POSITIVE!"
 40 IF N <= 0 THEN GOTO 10 40 IF N <= 0 THEN GOTO 10
 50 PRINT "THANKS! YOU ENTERED "; N 50 PRINT "THANKS! YOU ENTERED "; N
Line 827: Line 827:
  
  
-== CHAPTER 4: ADVANCED STELLAR BASIC PROGRAMMING +== CHAPTER 4: How to write games in Stellar BASIC
-** CHAPTER 4: ADVANCED BASIC PROGRAMMING** +
 In this chapter we will demonstrate some advanced programming techniques by writing a real game in Stellar BASIC. Today's game is ROBOT CHASE, the classic game that inspired BSDgames' 'robots'. In this chapter we will demonstrate some advanced programming techniques by writing a real game in Stellar BASIC. Today's game is ROBOT CHASE, the classic game that inspired BSDgames' 'robots'.
  
Line 882: Line 880:
 Let's make it more exciting; let's draw the player, and a robot. Let's make it more exciting; let's draw the player, and a robot.
  
-<codify BASIC+<codify BASIC>
     10 LET PX = 19     10 LET PX = 19
     20 LET PY = 11     20 LET PY = 11
Line 944: Line 942:
     240 RETURN     240 RETURN
  
-The above demo program checks for keys 10 times a second (WAIT 100). To check 50 times a second, try WAIT 20. Instead of WAIT, the program could be doing other things, like playing music or animating sprites! That's the power of a HASKEY loop -- but not every program needs to use that kind of input loop.+The above demo program checks for keys times a second (WAIT 200). To check 10 times a second, try WAIT 100 (i.e. 100ms). Instead of WAIT, the program could be doing other things, like playing music or animating sprites! That's the power of a HASKEY loop -- but not every program needs to use that kind of input loop.
  
 ==== Our ROBOTS input loop ==== Our ROBOTS input loop
Line 1095: Line 1093:
     4900 END     4900 END
  
-Finally, this would be a boring game if the robot didn't try and catch you! Here's how to make the robot move:+This would be a boring game if the robot didn't try and catch you! Here's how to make the robot move:
  
     140 REM MAKE ROBOTS MOVE     140 REM MAKE ROBOTS MOVE
Line 1105: Line 1103:
     7040 IF RY > PY THEN LET RY = RY - 1     7040 IF RY > PY THEN LET RY = RY - 1
     7900 RETURN     7900 RETURN
 +
 +And let's also add a beep every time the robots move, to add to their dread. You can read more about the PLAY command in [[SD-8516 Stellar Basic#Music]].
 +
 +    7100 PLAY "T120 W1 V5 O2 L24 B"
  
 If you play the game, you will notice the collision check doesn't work. Why? It's because you are checking for a collision on line 2500 before you move the robots. You need to check after. Delete line 2500 and type it in again as line 160: If you play the game, you will notice the collision check doesn't work. Why? It's because you are checking for a collision on line 2500 before you move the robots. You need to check after. Delete line 2500 and type it in again as line 160:
Line 1113: Line 1115:
 After this, you have the basis for a playable game. You could add: After this, you have the basis for a playable game. You could add:
  
-* Levelswith more robots with arrays, for example RX(3) for the third robot's RX.+* Levels with more robots -- using arrays, for example RX(3) for the third robot's RX.
 * A stone (junk pile) that kills robots when they touch it (they crash). * A stone (junk pile) that kills robots when they touch it (they crash).
 * Robot collisions which create crash-piles * Robot collisions which create crash-piles
Line 1121: Line 1123:
  
 === ROBOTS.BAS Complete Program === ROBOTS.BAS Complete Program
-Here is the complete program:+The source code for ROBOTS.BAS is listed on the BASIC Programs page:
  
-<codify BASIC> +* [[Stellar BASIC Programs]] 
-10 LET PX = 19 +Direct link[[https://www.appledog.ca/wiki/doku.php?id=sdb:robots|ROBOTS.BAS source code]]
-20 LET PY = 11 +
-30 LET RX = 1 +
-40 LET RY = 1 +
- +
-100 REM DRAW MAP +
-110 GOSUB 1000 +
-120 REM GET PLAYER INPUT +
-130 GOSUB 2000 +
-140 REM MAKE ROBOTS MOVE +
-150 GOSUB 7000 +
-160 REM CHECK FOR COLLISION +
-170 IF PX = RX THEN IF PY = RY THEN GOTO 4000 +
-180 REM LOOP UNTIL QUIT +
-190 GOTO 100 +
- +
-1000 REM DRAW MAP +
-1005 VSTOP +
-1010 CLS +
-1020 LET A = ASC("*") +
-1030 FOR X = 0 TO 39 +
-1040 CHARXY X, 0, A +
-1050 CHARXY X, 24, A +
-1060 NEXT X +
-1070 FOR Y = 0 TO 24 +
-1080 CHARXY 0, Y, A +
-1090 CHARXY 39, Y, A +
-1100 NEXT Y +
-1110 LET PC = ASC("@"+
-1120 LET RC = ASC("r"+
-1200 CHARXY PX, PY, PC +
-1300 CHARXY RX, RY, RC +
-1800 VSTART +
-1900 RETURN +
- +
-2000 REM *** SECTION B) INPUT LOOP +
-2010 LET K = GETKEY() +
-2015 IF K >= 97 THEN LET K = K - 32 +
-2020 LET L = ASC("H"+
-2030 LET D = ASC("J"+
-2040 LET U = ASC("K"+
-2050 LET R = ASC("L"+
-2060 LET Q = ASC("Q"+
-2200 IF K = L THEN GOSUB 5000 REM MOVE LEFT +
-2210 IF K = D THEN GOSUB 5100 REM MOVE DOWN +
-2220 IF K U THEN GOSUB 5200 REM MOVE UP +
-2230 IF K = R THEN GOSUB 5300 : REM MOVE RIGHT +
-2240 IF K = Q THEN GOSUB 5400 : REM QUIT +
-2900 RETURN +
- +
-4000 REM ROBOT CATCHES YOU +
-4010 CLS +
-4020 ? "OH NO! THE ROBOT CATCHES YOU.+
-4030 ? "GAME OVER." +
-4900 END +
- +
-5000 REM MOVE PLAYER LEFT +
-5010 LET PX = PX - 1 +
-5020 IF PX < 1 THEN LET PX = 1 +
-5030 RETURN +
-5100 REM MOVE PLAYER DOWN +
-5110 LET PY = PY + 1 +
-5120 IF PY > 22 THEN LET PY = 22 +
-5130 RETURN +
-5200 REM MOVE PLAYER UP +
-5210 LET PY = PY - 1 +
-5220 IF PY < 1 THEN LET PY = 1 +
-5230 RETURN +
-5300 REM MOVE PLAYER RIGHT +
-5310 LET PX = PX + 1 +
-5320 IF PX > 38 THEN LET PX = 38 +
-5330 RETURN +
-5400 REM QUIT +
-5410 CLS +
-5420 PRINT "QUIT GAME" +
-5430 END +
- +
-7000 REM MAKE ROBOT MOVE TOWARDS PLAYER +
-7010 IF RX < PX THEN LET RX = RX + 1 +
-7020 IF RX > PX THEN LET RX = RX - 1 +
-7030 IF RY < PY THEN LET RY = RY + 1 +
-7040 IF RY > PY THEN LET RY = RY - 1 +
-7900 RETURN +
-</codify>+
  
 == NEXT STEPS == NEXT STEPS
sd/sd-8516_user_s_guide.1774613780.txt.gz · Last modified: by appledog

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki