Simple example of conditions, loops, colors, shapes and variables (complete remarks) by Yskonyn9th Feb 2006 20:48
|
---|
Summary Simple example of how to make conditions give feedback on screen and learn to play with remarks, colors, shapes, variables, loops and IF statements. Description This little example draws a box on screen and checks for two conditions: Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com REM -Created by R. Ph. Kraak on 09-02-06- REM -RKGAMESProductions (RKGP) 2006- REM ------------------------------------- REM Setup main program cls `clear the screen from rubbish set display mode 1024,768,32 `set display resolution show mouse `keep the mouse visible REM Setup initial counter conditions counter=0 `counter for amount of clicks set cursor 500,500 `define position of the counter on screen ink rgb(0,255,0),0 `make sure the color is green print "Successful clicks: ",counter `create the counter on screen REM Now we're going to make the technical bits REMSTART In the following part we've setup a simple loop which checks for the left mousebutton being pressed and checks the position of the mousecursor. If it's pressed while over the box then all conditions are met and it will change the color of the box to green, plus a counter will show up. REMEND do if mouseclick()=1 AND MOUSEX()=>100 AND MOUSEX()=<200 AND MOUSEY()=>100 AND MOUSEY()=<200 cls `make sure nothing gets overlapped counter=counter+1 `increase counter by one with every successful click set cursor 500,500 `position cursor to display text at specific loc print "Successful clicks: ",counter `update the counter ink rgb(0,255,0),0 `change to green color box 100,100,200,200 `and update the box else ink rgb(255,0,0),0 `if there's no success turn the color back to red box 100,100,200,200 `and update the box endif loop |