Skip to main content

(IV) Draw some colored squares: line -step

Hello everybody!


Let's enrich our first code drawing four colored squares.
This is the result of our new code:
An screen to play with 400 pixels of width and 300 pixels of height and four squares of 32x32 pixels one in each corner. The white square is painted or filled with same color.

Let me explain the new keywords used:

  • line to draw a line between a point referenced with its coordinates (value in axis x,value in axis y) and an increment/decrement in pixels form this point -step(inc/dec in axis x,inc/dec in axis y) and two parameters separated by comma, the first is the color and the second is optional, if you used it you can put a b that means box or bf that means box filled.
Try changing color values from 0 (black or transparent) to 15 (white) and experiment with the parameters.

This is enough by now, in the next entry we will make great advance learning a change in the structure of the code because the famous game loop.

Contact me for any question, see you!

Go to the next entry
Go to the previous entry
Go to the first entry

Comments

Popular posts from this blog

(V) Game loop, variables, dim as boolean, if then else, multikey, false, true, do loop until

Hey everybody! Take a look at the code of the day: The result of execute our new code will be the same as the obtained with the code of the last entry but you must press Esc key to exit: An screen to play with 400 pixels of width and 300 pixels of height and four squares of 32x32 pixels one in each corner. The white square is painted or filled with same color. The screen is being draw again and again and again until you press Esc key. Let me explain the new keywords used: dim as boolean  as const as but with dim we are telling that the label (in our case finish and kescape) will have a variable value. In the case of boolean this value can be false or true. do loop until to make a loop that will repeat the code inside the instruction until the condition after until is resolve to true. if then else  to execute the code inside the instruction if the condition is resolve to true, else to execute an alternate code if the condition is  not resolve to true...

(III) Make an screen to play: ', const as integer, screenres, sleep & end

Come on everybody! Let's see our first code to make an screen to play. Let me explain the keywords used: '   t o add comments to the code, very useful to understand even the code made by ourselves. Used alone in a row or at the end of an instruction. const as integer to declare labels as integer numbers that contain constant values, non modifiable along the program. In this case w and h are constants. We must separate different consts with comma. screenres to do an screen to play, we have to tell two parameters the width and the height of the screen. We must separate parameters with comma. sleep to wait until a key is pressed to see the screen that otherwise will close too fast. end to end the program.  And the structure of this code not too far from the structure of a larger one: DESCRIPTION DECLARATIONS INITIALIZATIONS Main code ENDING In FBIde you can run the code pressing function key F5 or clicking Quick run icon This is the result of our ...

(VII) Movement: arrow keys, and, +=, -=, variable coordinates

Howdy everybody! Take a look at the new code of the day: In this code we have defined new keyboard scan codes for the arrow keys, see it in the DECLARATIONS as constants and declare variables to control if the keys are pressed or not, like we did it with key escape. Here x and y that are the coordinates of the white square will turn into variables because we will move this square then the value of the coordinates will be variable. When we DO UPDATE this time we will check also the four possible arrow keys and checking not to go with our white square outside our screen, otherwise the square will hide, you can prove it. Notice that the condition is multiple, using and to check that both conditions are true at the same time to change the value of the corresponding variable. We increment or decrement x or y with 1 (1 pixel), to go up y-1, right x+1, down y+1 or left x-1. This way: To increment we use the form variable+=amount of increment, for exemple x+=1 To de...