- FOR VAR = 0 TO 5
- ...
- NEXT VAR
- FOR VAR = 0 TO 10 STEP 2
- ...
- NEXT VAR
Alright, enough talk. Lets get to some code.
- ACLS:VISIBLE 1,1,0,0,0,0
- COLOR 15,11 'Set the color of the console to blue background with white characters
- CLS
- @MAINMENU
- LOCATE 8,4 'Set our cursor position where we print to 8,4
- PRINT "Petit Dungeon"
- LOCATE 11,9 'Set our cursor position to 11,9
- PRINT "> Start"
- LOCATE 11,11
- PRINT " Quit"
- 'Set our Box X,Y, Width, and Height
- BX=9:BY=7
- BW=11:BH=6
- GOSUB @DRAWBOX
- BGMPLAY 0,4 'Play some background music, give it ID #0
- CSRPOS = 1 'Set our default cursor position to 1(Top)
- @MMLOOP 'Our main menu loop
- 'If the up button was pressed, set the cursor position, play(beep) a sound effect, and update our pointer.
- IF BUTTON(2) == 1 THEN CSRPOS = 1:BEEP 2:LOCATE 11,11:PRINT " ":LOCATE 11,9:PRINT ">"
- 'Move our cursor down if the down key is pressed
- IF BUTTON(2) == 2 THEN CSRPOS = 2:BEEP 2:LOCATE 11,11:PRINT ">":LOCATE 11,9:PRINT " "
- 'If they press A and its cursor position 1(Top) then play the confirm sound and quit
- IF BUTTON(2) == 16 AND CSRPOS == 1 THEN BEEP 3:GOSUB @ENDGAME
- 'If the buttom option is chosen, play the cancel sound and quit
- IF BUTTON(2) == 16 AND CSRPOS == 2 THEN BEEP 4:GOSUB @ENDGAME
- GOTO @MMLOOP
- @ENDGAME
- BGMSTOP 0 'Stop playing sound #0 (Our bg music)
- END
- 'Our function to draw a box
- 'Arguments: BX, BY, BW, BH
- @DRAWBOX
- 'Draw the top and bottom lines of our box
- FOR LX = BX+1 TO BX+BW-1
- LOCATE LX, BY
- PRINT "─"
- LOCATE LX, BY+BH
- PRINT "─"
- NEXT
- 'Draw the left and right sides
- FOR LY = BY+1 TO BY+BH-1
- LOCATE BX,LY
- PRINT "│"
- LOCATE BX+BW,LY
- PRINT "│"
- NEXT
- 'Draw our box corners
- LOCATE BX,BY
- PRINT "┌"
- LOCATE BX+BW,BY
- PRINT "┐"
- LOCATE BX,BY+BH
- PRINT "└"
- LOCATE BX+BW,BY+BH
- PRINT "┘"
- RETURN
Okay, so that might seem daunting and super confusing. Just take your time reading it and feel free to play around with the code. Change things, break things, fix them. That's what its all about, right? =)
QR Code for this Tutorial
Homework
Okay, I am going to start doing this a little differently. Rather than explain them here I think it is time to teach you about referencing stuff in the manual if you don't already. It will help you more in the long run. The way it works is you press the help icon in the bottom left of the screen and find the topic you need to know something about and then you find the command you need after you pick the topic. From here on I will tell you the topic that the new commands are located and want you to look them up yourself. You may know the old saying: "Give a man a fish, and he will eat tonight. Teach a man to fish, and he will eat forever."
Topic 9: Sound Related Table (For sound/music reference)
Topic 21: Repeat/Comparison
- FOR~ TO~ STEP
Topic 23: Basic Console Commands
- COLOR
- LOCATE
Topic 43: Basic Audio Commands
- BEEP
- BGMPLAY
- BGMSTOP
This is such a great blog/tutorial! thanks for doing these and please post more!!! thank you!
ReplyDelete