How To

How to apply instructions to your character model?

0

tactics_pvp 2020-02-06 07:51 (Edited)

Here is my character data set:

#2:MAIN CHARACTERS
00000000000000000000000000000000
3820003C3030CC000010303E00000000

From my still learning, tiny coding knowledge:

Usually, with Unity, Unreal engine or Python code.


You would assign stuff a variable to recall it.

Example (no code in this example - just a basic explanation) Unfortunately, I don’t know how to program what I a saying, so here goes my explanation:

EXAMPLE:
STARTING CODE BLOCK is a VARIABLE named... ARM (as in your human arm)

since this is the start of the code block, all the instructions below it, are instructions for the arm variable. Therefore...

BODY OF CODE BLOCK:
If arm, hits wall,
it should bounce back,
unless, does not hit wall.

—- END OF EXAMPLE—-


With the example I expressed above... wouldn’t that be the same for my character model? (If I want to give it instructions to run, jump, shoot.. etc) Wouldn’t I assign it a variable?

so whenever I am referring or providing instruction to my character model, I call it by it’s variable name?

If so, how do I that?
Is it like this:

X = #2:MAIN CHARACTERS
00000000000000000000000000000000
3820003C3030CC000010303E00000000


Those two lines for the character model is throwing me off.

Or worst... do I have to keep typing out and/or copying and pasting that character data set, every time I want to provide instructions for my character model?


I hope - - I’m not confusing you guys, with my way of explaining, what I cannot yet do in code for a better a visual example.

(I tried looking at some of the programs people have created in here, I don’t see where they assigned their character data set a variable) I tried looking at the Alice program, since it’s closer to what I am trying to create (side scrolling) but I cannot see how they gave those instructions to their character model.

Alice:

https://lowresnx.inutilis.com/topic.php?id=967


Thanks.


nwallen 2020-02-06 09:21

More like the opposite of what you are trying. #2:MAIN CHARACTERS is rom data think like a pool of data in this case images. What you want to do is assign a sprite to part of that data(the character you want to draw).

SOMETHING LIKE:

GAMEPAD 1
DO
X=56
Y = 56
IMAGE = 1
SPRITE_NUMBER
IF LEFT TAP(0) THEN X = X - 1
IF RIGHT TAP(0) THEN X = X + 1
SPRITE SPRITE_NUMBER,X,Y,IMAGE
WAIT VBL
LOOP

#2:MAIN CHARACTERS
00000000000000000000000000000000
3820003C3030CC000010303E00000000

IMAGE is the character you want to draw from the "MAIN CHARACTERS" set. X and Y are the NX pixel positions you want to draw at and the SPRITE is where the magic happens.

The character data only needs to be there once. Not sure if having multiple will cause issues.

The EDITING section in the documentation has an example where they changed the 'A' to a custom character.


tactics_pvp 2020-02-06 10:09 (Edited)

Ah, yes. I think I am getting that part.
(Understanding the pool as you say, and how correlates to providing the sprite image, I call in from the data set) Ok.. some horizon in my mind.

Mentally, for some reason, I kept thinking I am supposed to know AND choose a number, within that second line you provided. Basically I had to choose image from there by it’s numerical value.

Thank goodness it’s not that. I get it now - I think.

The number 1 is from the save file (or rom) that is housing the sprite set I created. Due to the data set already being present in the code editor, NX know, if I choose 1, it’s the first sprite from the set of 4, that I created. I guess I would choose (2) for the image stored in the 2 of 4.

Thank you, that cleared things up on that front.
——————————————————————————

But here’s the other part of my confusion that was part of my initial post:

How do I create functions to assign the sprite?

Y = Shoot?
B = Jump?

ie.... creating jump function that I will assign a variable too?

This part is destroying my brain cells. I have been here since last night 8pm, it’s now 4:08am... and I have not budged from where I started. I think I may be going insane.

My brain cells are mush.


was8bit 2020-02-06 10:49

#2:MAIN CHARACTERS
00000000000000000000000000000000
3820003C3030CC000010303E00000000

Is the raw data file.. you MAY use COPY PASTE if you are clever with it and want to directly copy characters from one game to another..

USUALLY you will want to use the tool CHAR DESIGNER to access this file, and edit your characters... also, use this tool to see what char# is assigned to each graphic...

In CODE you access your graphics via it's char number... so

CELL X,Y,char# will place the graphics stored as char# and place that graphic onto cell X,Y


was8bit 2020-02-06 10:51

Your code can read what is on the screen with check=CELL.C(X,Y)... the variable i called check (you can use any variable name there) will have the char# that is at cell x,y.. if cell x,y is empty, check will be zero


was8bit 2020-02-06 10:52 (Edited)

SPRITES are different then charactes on a background layer, that is a different discussion, but sprites also use character graphics..


was8bit 2020-02-06 10:54

And, technically, background layers and sprites do not actually hold any graphic data, they only hold referencs #'s that refer to the graphics store as characters :)


was8bit 2020-02-06 10:59

I recomend something simple.. check this out..

https://lowresnx.inutilis.com/topic.php?id=984

Competely disect it and try to understand it.. post any questions there about it... and try to level up to a game about that level and make a game for yourself :)


Timo 2020-02-06 13:37

I think you start too deep, better start much simpler.
- create a sprite and show it
- make it move with the gamepad
- create a background
- show the background with the sprite
- make the sprite stop at walls etc.

Don’t think about jumping before you understand the basics :)


was8bit 2020-02-06 17:37

Ah, but i understand the curious spirit... ;)

Yes, Patience and start simple :)


tactics_pvp 2020-02-07 02:57

@Timo

Thank you.

Yes... exactly WHAT I needed. Someone to tell me WHERE to start, since I wouldn’t know where to start. In my mind... I thought what I was trying to do WAS the simple part.


Going off what you advise:


-create a sprite and show it
-make it move with the gamepad
-create a background
(This part ^^^^^ I did with your youtube guide and your online manual)

-show the background with the sprite
(I think I left off on this part ^^^^ with your youtube vid yesterday)


THIS is where I know I will be lost:
-make the sprite stop at walls etc.

For that sprite to stop at wall... wouldn’t that require collision? (a way for NX to detect)

If so... I would have to code that collision as a function?

Then once I code collision as a function..

I declare it with DIM and assign it a variable?

After I assign it a variable, I call that variable within the (wall) code block and the (sprite) code block?

Am I correct on the way to go about it coding concept?


tactics_pvp 2020-02-07 03:01 (Edited)

@was8bit,

Thank you. I will definitely check out that link you provided and see if I can understand the code.

If could deconstruct it, chunk by chunk, starting from the top - I might be able to “understand” what’s going on.

Only way I’ll get that “understanding” is if...

When I remove some of the code - I notice what goes wrong in the game. Hopefully I catch that visual cue.


was8bit 2020-02-07 05:33

That is how i learn to :)

Dont hesitate to post question on my game concerning how i did things in the game :)


was8bit 2020-02-07 05:38

Sprite to sprite collision is automatically done wirh HIT (see under SPRITE)

Cell to cell is EZ.. CELL.C(x,y) lets your code SEE what is in that background cell..

Sprite to cell is trickier... ask again once you get that far.. for now maybe stick to sprites only like my SIMPLE SHOOTER does...


tactics_pvp 2020-02-07 05:44

@was8bit

As always... you’re a blessing. Thank you for answering my questions.

I have been removing parts of your code and putting them back to see what the are doing. The only ones that hit me with a “syntax error” is the code usually dealing with and or showing numbers 18*8 I think being one of those.

I also have the online NX document open on split view so I can look up some of the keyword you have been using such as RANDOMIZER and TIMER.

I will definitely have questions for you once I get some more time on the code.


was8bit 2020-02-07 05:47

REM in front of a line of code is a very easy way to "remove" it, in that REM turns that line of code into an ignored REMARK ;)

Then remove the REM to reactivate that line of code ;)


Log in to reply.