japanese 2020-01-13 03:33
was8bit 2020-01-13 04:27
The reason for the error is because the variables ended up being inside a SUB... calling a sub from another sub is tricky... so I
1) used GOSUB from your main DO LOOP so the variables SX,SY TX,TY are not hidden inside a SUB... remember, you originally had them inside a SUB, which means they where exclusively inside the sub only and even though the names where identical to variables outside the sub, the sub variables are not seen by the main program... (unless you make them GLOBAL)
2) I tweaked the movement routine code... included ability to let it know which SPRITE was moving, increased movement to account for sprites that are 16x16 pixels big, and added code to update the sprite position variables
... i dont like how one sprite hesitates while the other one moves, so i will change the code to fix that...
was8bit 2020-01-13 05:08 (Edited)
Ooo...kay... (ok stretched out slowly)....
I had to rearrange everything to simplify the code...
1) renamed variables so everything now is referenced by the SPRITE NUMBER (#0 = player, #1 = enemy)
The movement hesitation in previous version happened because WAIT VBL was being used multiple times, and everything halted until one sprite finished moving ... the fix for that was...
2) only use ONE WAIT VBL
3) use a timing index for each sprite that tracked movement for each sprite, i call it MOVE... it tracks how many times a character has moved, and stops movement at 16 pixels...
4) ONLY allow change in direction when movement is completed, this happens when MOVE=0 indicating sprite is not moving, and then can be given a new movement command (new direction)
... to summerize....
SUB now only initializes variables MOVE MX MY for the appropriate sprite, and thats it...
Each sprite's movement section is split into two possible things... if MOVE=0 then acquire new movement command (arrow keys or the simple AI i made for the enemy)... if MOVE>0 this means sprite is moving, so process that and once movement is done, reset MOVE to zero again..
This allows each sprite to update its movement by one pixel each cycle of the main DO LOOP, and more importantly, both sprite movements are updated at the same time.. no hesitation :)
was8bit 2020-01-13 05:22
Will explain these....
DIM GLOBAL X(1),Y(1),MX(1),MY(1),MOVE(1)
DIM GLOBAL is a double command, it makes these variable arrays GLOBAL
GLOBAL is a single command, it makes these regular variables GLOBAL
A GLOBAL variable is the same whether is in ANY SUB or in the main program
Non-global variables (called local by default) are NOT the same from one SUB to another SUB to the main program, even if they have identical spelling, all local variables inside a SUB are hidden from all other variables outside that SUB, even the ones spelled the same.. so in your first program TX inside the SUB is a different variable than the TX in the main program...
was8bit 2020-01-13 05:25 (Edited)
My variables in the GOOD version are explained....
(# represents the SPRITE NUMBER) 0=player, 1=enemy
X(#),Y(#) is the CELL coordinate of the sprite
MX(#),MY(#) is the direction of the sprite movement
MOVE(#) is the movement index for the sprite...
MOVE_TEKI is a variable i made as simple AI for the enemy... it allows the enemy to move in one direction for awhile before "deciding" to change directions ;)
was8bit 2020-01-13 05:31 (Edited)
Theoretically, this approach allows for more moving sprites... simply assign sprites in order, and a little tweaking to create a loop for the enemies can have more than one enemy... i will post an example...
japanese 2020-01-13 07:04
Thanks, Thanks, Thanks, …
I want to learn more deeply about lowres nx too.
How should I study?
was8bit 2020-01-13 08:57 (Edited)
You are very welcome !! :)
Well... asking questions always helps :)
Experimenting helps too....
... also, try to review others codes, like ones i have made for you, and try to understand how they work...
.. read others posted questions, and the answers ...
Try try try try..;)
Also, go thru the HELP section.... ask questions about things you dont know yet..
was8bit 2020-01-13 08:59
Timo has posted a basic help...
was8bit 2020-01-13 09:01 (Edited)
And REALLY read the entire HELP text, top to bottom, whether you understand everything or not.. it is as simple or as deep as you want it to be ;)
was8bit 2020-01-13 09:15 (Edited)
A contrast of Lowres NX against other game makers:
Think of a TEXT ONLY game maker... all the text characters are the same size, tiny squares that are placed on a grid on the screen..
HOW could you make games? The code can place text charactes on the screen... the code can read what characters are already on the screen... with clever planning you CAN make very simple games...
This is the simple foundation of NX... simple little graphic blocks that fill up a grid on the screen... you can put them on the screen, you can read what has been placed on the screen....
SPRITES borrow these graphic blocks and can be used to float about the screen, so are kinda special and different
SUBS are powerful yet tricky...
MEMORY is also powerful and tricky...
I would try to:
1) learn backgrounds well, including TEXT, NUMBER
2) learn SPRITES well
3) learn basic NX language well, including ARRAYS,SUBS,
4) learn well: CHARACTER DESIGNER, BACKGROUND DESIGNER, SOUND COMPOSER
.... then you will be ready for the deeper stuff ;)
was8bit 2020-01-13 09:21 (Edited)
I also have posted lots of examples, as well reworks of the best of what other people have made.... you can explore these as well :)
japanese 2020-01-13 09:29
Thank you for the kind thoughts!
I want study lowres NX more and make good game!
Please kindly continue teaching me more stuff
was8bit 2020-01-13 09:33
I actually am a text character game maker at heart... so working a grid of graphics is my favorite thing to do :)
My game with original lowres was all text, made Nov 15 2016... i recreated an NX version here...
It is actually based on a paper version i made for kids to play... 6 players draw their favorite animal on a paper in front of them, and each gets their own number 1-6 on their paper...
on their turn, they start with 6dice... on each roll, they must choose only 1 dice to play... the dice they choose must go to the player who has the same number on their paper... so playing a dice#6 goes to animal#6... you feed that animal... keep rolling and playing 1 dice per roll until all the dice are played.... players count how much food their animal has been fed and add it to their animal's total..
After all players have played, whoevers animal has been fed the most wins the game :)
japanese 2020-01-13 13:34
I'll start with something easier !
was8bit 2020-01-13 15:17
The games your are making are wonderful :)
You know how to use character designer.. need to learn background designer
You are learning background... need to learn how to layer 2 backgrounds
You are learning SUBS, need to be good at SUBS and with GLOBAL
You need to learn how to add sound effects using SOUND COMPOSER
You need to learn how to add animation to your sprites
Keep making games like you have been... and add to your programing skills as i have suggested....
We will keep adding more things as you keep learning ... i have a feeling we will be getting to the deeper stuff very soon ;)