02-05-2025, 04:41 PM
To get o3 to make the asteroid clone, I fed it a prompt from a text file I made up. I don't have the exact one, but I do have a text rather similar. The only changes I needed to make were two more prompts, one to add a maximum speed, and one to make the asteroids solid. It can sometimes make little mistakes, like trying to COMMON SHARE an array instead of DIM SHARE.
The prompt:
Hello, I'm going to teach you how to code in QBASIC 64 Phoenix Edition, aka QB64PE. QB64PE is slightly different than QBASIC in that it needs all of it's code before the other functions. I'll give you an example.
[CODE EXAMPLE STARTS]
CONST SCREENSIZEX = 352 ' 352x256 gives a size of 32x24 ASCII characters, or the game could be programmed by pixel drawing
CONST SCREENSIZEY = 256
COMMON SHARED viewSizeX, viewSizeY
DIM SHARED PIXELMAP(SCREENSIZEX, SCREENSIZEY) ' Note that arrays need to be DIM SHARED, not COMMON SHARED
_FULLSCREEN
SCREEN _NEWIMAGE(SCREENSIZEX, SCREENSIZEY, 13) ' The third argument MUST be 13
_FONT 8 ' QB64 specific command to ensure the font is 8 x 8 in this mode
' You might use the next section in a game that has a player walking around a screen:
viewSizeX = 32 ' Farthest location right on the playscreen in 8-pixel wide blocks
viewSizeY = 24 ' Farthest location down On the playscreen in 8-pixel tall blocks
hPosx = 5 ' Hero character position X
hPosy = 5 ' Hero character position Y
' Main code loop here without a "main" function definition
f = moveCheck(hPosX, hPosY) ' If I wanted to call the function moveCheck
FUNCTION moveCheck (wPosX, wPosY) ' Moving on to functions and subs
' Code for a function called moveCheck would go here to check if the player can move on the map
moveCheck = 1 ' Returning a value of 1
END FUNCTION
[CODE EXAMPLE ENDS]
Another thing you need to know is how to take input. For polling the keyboard, use these options:
For moving down on screen:
IF _KEYDOWN(50) OR _KEYDOWN(20480) THEN
For moving left on screen:
IF _KEYDOWN(52) OR _KEYDOWN(19200) THEN
For moving right on screen:
IF _KEYDOWN(54) OR _KEYDOWN(19712) THEN
For moving up on screen:
For an action button, if one is needed, use the space key:
IF _KEYDOWN(32) THEN
For a second action button, if one is needed, use the B key:
IF _KEYDOWN(66) OR _KEYDOWN(98) THEN
For exiting the game, use ESC key:
IF _KEYDOWN(27) THEN
* Variables in QB64PE cannot start with an underscore.
* Another thing you need to know is how to return a value from a function. In QB64PE, the FUNCTION moveCheck (wTrueX, wTrueY) would use movecheck = 1 to set the value of 1 to return, then use EXIT FUNCTION (or wait until the end of the function) to leave it and send that value back.
* Every time you update the code working with me, please give me the full code.
* QB64PE requires a value to be received every time a function is returned. Please use f = FUNCTION() if you are going to use it without a value returned.
* Global variables need to be COMMON SHARED. Global arrays need to be DIM SHARED, with their size listed when declared.
* To call a subroutine, use the command CALL.
* To draw a box, use the command LINE (x,y)-(x,y), then the color number, then B or BF for box or box filled
* I like to use the variables ix for horizontal loops, iy for vertical loops, and ii and i2 for other loops.
* You can't have a string variable named INPUT$
* Commands not to use: STATIC, REDIM
* The command to clear the screen is CLS
At the end of the code, include the function
SUB ZLOCATE (wx, wy)
LOCATE wy + 1, wx + 1
END SUB
This lets us compensate for how LOCATE starts at 1 instead of 0, which can trip us up a lot. Use this function instead of LOCATE.
Add another function after that, a testing tool I can use to escape with a code.
SUB ESCAPE (code)
COLOR 15
ZLOCATE 10, 5: PRINT " "
ZLOCATE 10, 6: PRINT "ENDED WITH CODE:"; code; " "
ZLOCATE 10, 7: PRINT " "
END ' SYSTEM also works
END SUB
The third function will be ESCAPETEXT, something that might let us end the game with GAME OVER
SUB ESCAPETEXT (wStr$)
COLOR 15
xPos = 1
yPos = 5
IF wStr$ = "" THEN wStr$ = "No text sent"
ZLOCATE xPos, yPos: PRINT " "
ZLOCATE xPos, yPos + 2: PRINT " " ' Print before text in case text wraps
ZLOCATE xPos, yPos + 1: PRINT " "; wStr$; " "
END ' SYSTEM
END SUB
Today's task is to:
The prompt:
Hello, I'm going to teach you how to code in QBASIC 64 Phoenix Edition, aka QB64PE. QB64PE is slightly different than QBASIC in that it needs all of it's code before the other functions. I'll give you an example.
[CODE EXAMPLE STARTS]
CONST SCREENSIZEX = 352 ' 352x256 gives a size of 32x24 ASCII characters, or the game could be programmed by pixel drawing
CONST SCREENSIZEY = 256
COMMON SHARED viewSizeX, viewSizeY
DIM SHARED PIXELMAP(SCREENSIZEX, SCREENSIZEY) ' Note that arrays need to be DIM SHARED, not COMMON SHARED
_FULLSCREEN
SCREEN _NEWIMAGE(SCREENSIZEX, SCREENSIZEY, 13) ' The third argument MUST be 13
_FONT 8 ' QB64 specific command to ensure the font is 8 x 8 in this mode
' You might use the next section in a game that has a player walking around a screen:
viewSizeX = 32 ' Farthest location right on the playscreen in 8-pixel wide blocks
viewSizeY = 24 ' Farthest location down On the playscreen in 8-pixel tall blocks
hPosx = 5 ' Hero character position X
hPosy = 5 ' Hero character position Y
' Main code loop here without a "main" function definition
f = moveCheck(hPosX, hPosY) ' If I wanted to call the function moveCheck
FUNCTION moveCheck (wPosX, wPosY) ' Moving on to functions and subs
' Code for a function called moveCheck would go here to check if the player can move on the map
moveCheck = 1 ' Returning a value of 1
END FUNCTION
[CODE EXAMPLE ENDS]
Another thing you need to know is how to take input. For polling the keyboard, use these options:
For moving down on screen:
IF _KEYDOWN(50) OR _KEYDOWN(20480) THEN
For moving left on screen:
IF _KEYDOWN(52) OR _KEYDOWN(19200) THEN
For moving right on screen:
IF _KEYDOWN(54) OR _KEYDOWN(19712) THEN
For moving up on screen:
For an action button, if one is needed, use the space key:
IF _KEYDOWN(32) THEN
For a second action button, if one is needed, use the B key:
IF _KEYDOWN(66) OR _KEYDOWN(98) THEN
For exiting the game, use ESC key:
IF _KEYDOWN(27) THEN
* Variables in QB64PE cannot start with an underscore.
* Another thing you need to know is how to return a value from a function. In QB64PE, the FUNCTION moveCheck (wTrueX, wTrueY) would use movecheck = 1 to set the value of 1 to return, then use EXIT FUNCTION (or wait until the end of the function) to leave it and send that value back.
* Every time you update the code working with me, please give me the full code.
* QB64PE requires a value to be received every time a function is returned. Please use f = FUNCTION() if you are going to use it without a value returned.
* Global variables need to be COMMON SHARED. Global arrays need to be DIM SHARED, with their size listed when declared.
* To call a subroutine, use the command CALL.
* To draw a box, use the command LINE (x,y)-(x,y), then the color number, then B or BF for box or box filled
* I like to use the variables ix for horizontal loops, iy for vertical loops, and ii and i2 for other loops.
* You can't have a string variable named INPUT$
* Commands not to use: STATIC, REDIM
* The command to clear the screen is CLS
At the end of the code, include the function
SUB ZLOCATE (wx, wy)
LOCATE wy + 1, wx + 1
END SUB
This lets us compensate for how LOCATE starts at 1 instead of 0, which can trip us up a lot. Use this function instead of LOCATE.
Add another function after that, a testing tool I can use to escape with a code.
SUB ESCAPE (code)
COLOR 15
ZLOCATE 10, 5: PRINT " "
ZLOCATE 10, 6: PRINT "ENDED WITH CODE:"; code; " "
ZLOCATE 10, 7: PRINT " "
END ' SYSTEM also works
END SUB
The third function will be ESCAPETEXT, something that might let us end the game with GAME OVER
SUB ESCAPETEXT (wStr$)
COLOR 15
xPos = 1
yPos = 5
IF wStr$ = "" THEN wStr$ = "No text sent"
ZLOCATE xPos, yPos: PRINT " "
ZLOCATE xPos, yPos + 2: PRINT " " ' Print before text in case text wraps
ZLOCATE xPos, yPos + 1: PRINT " "; wStr$; " "
END ' SYSTEM
END SUB
Today's task is to:

