Nope, VAR/DIM is used for every kind of variable(Number, strings or array).
The difference with A=B-C is that your example is an implicit declaration of the variables meanwhile DIM/VAR do a explicit declaration.
DIM/VAR let you declare a variable. This sentence is useful when you create a function with DEF because the variable you use is based on the context.
Example:
'Global variable
VAR X$="WORLD"
DEF showX
VAR X$="HELLO" 'Varible that exist only inside showX
? X$;
END
showX
? X$
- Don't use goto or gosub. Use DEF instead of gosub.
- Don't repeat yourself. Try to create functions (Using DEF) instead of copy paste. That way, you have to do less changes in the future.
Finally, I recommend search in google "game programming patterns". I know this is not a OOP language but there are useful information to make things with less code, easier to understand and faster.
I don't recommend use : as new line because the code became hard to read.
Try to organize your code in a way that is easy to read. Some tips:
- Use commentaries to separate parts of your code.
- Try to write what your code do on process that are complex.
- Avoid programming in one line. Try to keep the length of each line less than 40 char to have a clear view of whats going on.
...
Motivation: In Smilebasic, arrays let you store a "dynamic" amount of elements. A static defintion is something like this:
VAR SP1,SP2
You see, there are two elements. You need to write another variable to create another.
With array:
VAR SP[0]
Here is an array with 0 elements, but if you use PUSH then you can have a dynamic number of variables without changing the code.
More attacks. I ended making other another array pool to handle them. Now I'm going to work again on the screen to build the folder since I haven't made code for inventory.
I think Person(JP) explanation isn't clear.
What AND does is compare the bit representation of two values and return the value build by the logic operator AND.
For example if you compare 3 AND 6 it will pass. 3 in bit is &b011 and 6 is &b110, and since the second bit match the returned value will be &b010 aka 2.
If you compare 3==6 you will get false since they are not the same number
FYI the file exported on LitterBox only contains the text of the MML
You need to use BGMPLAY to hear the song.
EXAMPLE:
VAR S$=LOAD("TXT:[nameOfYourSong]",0)
BGMPLAY S$
1. Load a custom sprite sheet using LOAD "GRP4:[nameOfFile]"
2. Use SPDEF to define the properties of the sprite.
3. Display the sprite using the definition number used on step 2.
Example:
VAR SP
LOAD "GRP4:MYSPRITES"
SPDEF 50,0,0,32,32,16,16,1
...
SP = SPSET(50)
I've done a lot since the last time but there still things left to be done. One thing I want to do are "attacks" that are alive(Example: thunderball that move slowly on the map or boomerang).
By the way, I don't know if I'll enter to smilebasicsource's contest. I want to do a game that use the gyro sensor but I'll see if can do something this weekend.
Another way to handle camera movement is to set an sprite that will serve as the camera and link all the entities to it with splink (Except the player since he's always on the middle of the screen.)
The you just need to move the camera sprite to move everything else.
Note that you need to ensure that the management number of each sprite is greater than the one used by the camera.
Well, I haven't seen your new code yet but you need to iterate the tree array on each loop and call spofs for each of them.
Since I see spset on the first pic, I assume that the code you posted is part of the initialization of your game.
You should use "TH GRP Editor" to edit sprites. It has way more features than the one provided by smilebasic paint. The program is in japanese, but is not hard to figure out what each option do.
V1.8.2 KEY:[KEJ23C3]
Miiverse id-name: thanks_0u0
Smilebasic is a "game" where you can make programs using a modification of the language "Basic".
Also, you can download the programs made by other people for free.
The pic that you see above is my attempt to do a game similar to megaman battle network.
By the way, use the parameters of the sprites instead of hard coding the box parameters on the "if" posted by @*J.P.*[P]£. (USE SPCHR to get those parameters)
If your sprite won't be on the middle of the screen(or if the image will change) then you must obtain the parameters and compare them with the coordinates of TOUCH.
There are two ways:
1.
Make a sprite that follow the touch event(TOUCH out TT,TX,TY) and has the propertie to collide with other sprites.
2.
Get the properties of the sprite with "spchr out x,y,w,h,a" and check if the touch event is inside the rectangle formed with x,y,w and h