Hello my DBpro buddies! JohnnyJohnson, let me explode your mind by furthering Phaelax's second technique.
My code with REM;
`An Example of the game loop and simple functions
`Lots of love, BFM
`======================
`Firstly, we activate & colour the backdrop, and the ink colour.
`I like to colour using hexidecimal, rather than the RGB command.
Backdrop On
Color Backdrop 0xFF000000
Ink 0xFFFFFFFF
`Then comes the game loop
`To control screen flicker, we'll use Sync On and manually sync the game per loop by calling before the loop "Sync".
Sync On
Do
`Set the cursor will reposition the text every loop. Test it out, turn it off, see what happens! Then change it's position.
Set Cursor 0,0
`Screen FPS command returns the frames per second. The more the merrier!
Print "Screen Frames: " ; Screen Fps()
`Now, here comes my unique code. Simply press 1-9 on the key board, and look what happens!
Print "Press a key, 1 to 9"
`VAL converts the keyboard button into a physical number when possible. Number One to nine = 1 - 9, but the letters A to Z won't return a VAL.
If Val(Entry$())
Player_Input$ = Entry$()
Endif
`We take the Player_Input, one to nine, and feed it into a hungry function!
Hello_World(Player_Input$)
`The function executes, then the loop syncs and starts all over again ^_^
Sync
Loop
End
`Here's where the function code is placed, outside of the game loop, after END.
`The player_input is fed into the function via Count$, and then Count$ is the maxiumum number of times "Hello World" can print on screen.
Function Hello_World(Count$)
Clear Entry Buffer
For Print_Again = 1 To Val(Count$)
Print "Hello World!!!"
Next Print_Again
Endfunction
`Pretty neat huh? I absolutely <3 DBpro ^_^
And below is the same code but without remarks;
Backdrop On
Color Backdrop 0xFF000000
Ink 0xFFFFFFFF
Sync On
Do
Set Cursor 0,0
Print "Screen Frames: " ; Screen Fps()
Print "Press a key, 1 to 9"
If Val(Entry$())
Player_Input$ = Entry$()
Endif
Hello_World(Player_Input$)
Sync
Loop
End
Function Hello_World(Count$)
Clear Entry Buffer
For Print_Again = 1 To Val(Count$)
Print "Hello World!!!"
Next Print_Again
Endfunction
Note how in my example, I did not use the CLS command? This is something you should make a note of, and learn when, or if, you should be using CLS.
Now, see if you can't optimise my code, or improve on it! That way I can learn something in return, and we all win!
EDIT: Here's an example of the power that we've unleashed here.
Backdrop On
Color Backdrop 0xFF000000
Ink 0xFFFFFFFF
Make_Cube(0xFF00FF00)
Sync On
Sync Rate 30
Do
Set Cursor 0,0
Print "Screen Frames: " ; Screen Fps()
Print "Press a key, 1 to 9"
If Val(Entry$())
Player_Input$ = Entry$()
Endif
Hello_World(Player_Input$)
Update_Cube()
Sync
Loop
End
Function Hello_World(Count$)
Clear Entry Buffer
For Print_Again = 1 To Val(Count$)
Print "Hello World!!!"
Next Print_Again
Endfunction
Function Make_Cube(Colour)
Make Object Cube 1, 10
Color Object 1, Colour
Rotate Object 1, 0,0,45
Fix Object pivot 1
Endfunction
Function Update_Cube()
Rotate Object 1, 0,Object Angle Y(1)+1,0
Endfunction