Discussion

if up(0) then y=y-1 <—Question does zero represent neutral?

0

tactics_pvp 2020-02-04 02:41 (Edited)

Moderator,

I hope I placed this in the correct forum. Being this is a question, I thought it’s a discussion? Apologies if I am wrong with that.

Three Questions in this post:

QUESTION 1:
I am following the current lesson in the
https://lowresnx.inutilis.com/docs/manual.html

The following code block is presented:

gamepad 1

x=76
y=60
do
if up(0) then y=y-1
if down(0) then y=y+1
if left(0) then x=x-1
if right(0) then x=x+1


I just want to make sure I understanding this stuff correctly.
Regarding the (0) - those are the neutral positions correct?

Y is vertical on the 2D axis
X is horizontal on the 2D axis

Thus the code block is saying:
X = 76 (Max Horizontal Coordinates with positive path headed east)

Y = 60 (Max Vertical Coordinates with positive path headed south)

If the zero inside the parameters stands for neutral position, the gamepad understands the instruction as...

DO the following +1 increments on, the set path, the longer said direction is held down. (Left, Right, Up, Down.. etc)

Is this line of thinking correct?

The lesson here for me:
Even after I memorize coding... I must still grasp basic understanding of 2D axis and it’s coordinates path.

Here are my confusion areas:

X=76
Why is X set to 76? Is this arbitrary?
Is it because that’s the max it can go for whatever reason?
Or is this the max screen size of an iPad?

76 is throwing me off - when I have those thoughts lingering.

Once I get answer - I am assuming it applies to Y=60


QUESTION 2:
How is this code able to run letter A when I test the gamepad example? I do not see the letter A typed anywhere in the code - so how is it being called? This code:

gamepad 1

x=76
y=60
do
if up(0) then y=y-1
if down(0) then y=y+1
if left(0) then x=x-1
if right(0) then x=x+1
sprite 0,x,y,225
wait vbl
loop


QUESTION 3:
I thought variables are presented with a $ in front.

How is...
x=76
y=60

working in the code block without error?
Shouldn’t it be:
X$ = 76
Y$ = 60


nwallen 2020-02-04 05:57

QUESTION 1:
"Regarding the (0) - those are the neutral positions correct?" The (0) is the player number. 0 for player 1 ,1 for player 2
"X=76 Y=60" position in the middle of the screen.
"if left(0) then x=x-1" if player 1 presses left add 1 to x. X = 77

QUESTION 2:
"sprite 0,x,y,225" this is A. I cannot remember where I got that info from. But checking the section after you see how to change it from 'A' to custom art.

QUESTION 3:
"String variable names end with a $ symbol," from the manual.NAME$ "Bill",AGE=40
"X$ = 76" will through a Type mismatch error.


was8bit 2020-02-04 07:11 (Edited)

The character 225="A" is a bit of a secret trick....

- a "secret" default font set is copied from file 0 IF
1) file 0 has not been saved to
2) page 4 of your character set is not used

To see how character 225="A" do this...

1) Open up Char Designer
2) go to page 4
3) push the FONT button
4) select a font set to load
5) tap the character "A"
6) now, what # does it say "A" is? ... it is 225

You can use cell x,y,255 OR text x,y,"A"... the end result is the same, character 255 is placed into cell x,y

TEXT just figures out all the math for you :)


was8bit 2020-02-04 07:13

You can create your own font set by loading up a font to page 4, edit the text, and save.. now whenever you use TEXT or FONT it will use YOUR custom made font set ;)


was8bit 2020-02-04 07:15

Screen coordinates can be confusing... CELL used cell coordinates, which is 0 to 19 horizontally and 0 to 15 vertically, with 0,0 at the top left corner

SPRITES use the actual pixel coordinates, and as each cell is 8x8 pixels, CELL 1,1 = SPRITE 8,8


was8bit 2020-02-04 07:19

You can convert between string variables and numeric variables...

myage=VAL(inputage$)
inputage$=STR$(myage)
TEXT 0,0,STR$(myage)
NUMBER 0,0,VAL(inputage$),3


was8bit 2020-02-04 07:22

Conversion can be tricky...

PRINT VAL("A8A")=0
PRINT VAL("8A")=8
PRINT VAL("8A3")=8


Timo 2020-02-04 07:27

Don’t worry too much about the forum categories, it’s just a little help to organize things. Sometimes they don’t fit perfectly.

Q2: The default font is preloaded to the end of the characters memory. This is why you can use letters as sprites, too. Fonts and tiles and sprites all use the same memory area.


Timo 2020-02-04 07:28

A is 225


was8bit 2020-02-04 08:13

Good catch... my partial dislexia kicked in...


G-9 2020-02-04 17:54

Question 2 : Letters characters are auto-drawed between character 225 ~ 255


tactics_pvp 2020-02-05 01:04 (Edited)

Thank you every one.

@nwallen thank you for question 1 break down. That one kicked my behind trying to understand what you were explaining, because... I was still parlaying, what you were saying into my understanding of it, instead of the other way around.

Had to re-read your Q1 answer a few times. I get it now.

Also, thank you for correcting me in my thought process.
Only strings require a $ symbol.


tactics_pvp 2020-02-05 01:11

@was8bit regarding this quote from you:

“Screen coordinates can be confusing... CELL used cell coordinates, which is 0 to 19 horizontally and 0 to 15 vertically, with 0,0 at the top left corner

SPRITES use the actual pixel coordinates, and as each cell is 8x8 pixels, CELL 1,1 = SPRITE 8,8”

Two questions from me on this one:

Q1:
Technically speaking since NX is pixel console... does x=76, y=60 (are these 76 & 60 pixels or 76 & 60 points?)

Q2:
Is the center of a big iPad screen and small iPhone screen always the same:
x=76
y=60

According to @nwallen, these variable values are the center of the screen.

(I am assuming the variable values representing center of screen would have to change according to screen size?)


tactics_pvp 2020-02-05 01:13

@Timo and @was8bit
Thank you regarding the secret “A”, which is 225 (stuffed somewhere in the backend code of NX) I now understand.


was8bit 2020-02-05 04:30

NX coordinates.... seeing is believing....

Try playing around with these....

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

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

These SHOULD help clarify things :)


was8bit 2020-02-05 04:42

You said "Technically speaking since NX is pixel console..."

Let me correct that statement...

"NX is NOT a pixel oriented system, it is a CELL BLOCK system where CHARACTER BLOCKS from memory are places into CELL BLOCKS on the screen.. like a tiled floor or tiled wall, character blocks MUST go into a fixed tiles space on the screen

TRUE, each indivual character block is made up of 8x8 or 64 pixels, but you can NOT place an indivual pixel anywhere you want to on the screen...

You CAN use sprites, but sprites are a special application and even they must acquire their images from character graphic blocks ...

Graphically speaking, you have 2 ways to place your character blocks onto the screen (which BTW is identical on ipads and iphones)..

1) directly placing indivual character blocks into a background using CELL coordinates
2) using SPRITES which use character blocks to create the sprite image using SPRITE cooridates..

... technically speaking, neither the backgrounds (BG 0, BG 1) or the sprites (0-63) actually hold any graphics.. they simply hold a reference number which links up to the actual character graphic.... NX uses the character graphics and places them on the screen based upon what char reference numbers you have put into background memory and in sprite memory ....


was8bit 2020-02-05 04:43 (Edited)

Since a background nor sprite actually holds any graphics, merely a reference number to a character graphic.. you can do tricks... i will post something for you to check out :)


... here you go, check it out :)

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


Timo 2020-02-05 07:34

Remember that NX is a virtual game console. It has fix specifications no matter on which device you play it. So its screen size is always 160x128 (virtual) pixels.


tactics_pvp 2020-02-05 16:29

@Timo
Ah.. yes, that helped a lot in me understanding the CELL concept. Thanks for the CELL breakdown @was8bit.

@Timo
Understood, it’s a virtual console, and so it has fixed specifications. Concept now grasped.

160x128 (speaking pixels correct?) I am literally lost on this part.
I keep thinking you mean 160x128 points, but then I’m wondering, does he mean pixels? Thanks.


tactics_pvp 2020-02-05 16:30

@was8bit

Thanks for the sprite trick. Interesting how one can find ways to get around certain limitations of hardware and what not. Very interesting.


Timo 2020-02-05 16:37 (Edited)

In NX you only think of 160x128 pixels. Of course it's scaled to the actual iPhone/iPad/Computer screen. So one NX pixel is not equal to one device pixel. In NX everything is virtual/simulated.


tactics_pvp 2020-02-05 17:33

@ Timo, thanks.

Looks like this video teaching me how old school consoles used cells, sprites and various other techniques due to limited ram. I can transfer what I learn here on to NX.

This youtube channel guy has must be a @was8bit relative? (name)

https://youtu.be/Tfh0ytz8S0k


tactics_pvp 2020-02-05 17:52

Wow,
I gleaned much from that video. He did a breakdown of an image and showed how some cells in the color gambit, were turned off and some on, to reserved ram.

Just wow the amount of work some of you guys put into your craft, then it produces the masterpiece.


tactics_pvp 2020-02-05 17:54

tried posting pictures but once I brought down to 128k, website is saying please add in recommended way, but doesn’t say which is the recommended way.

Would had loved to share the images from this video, fall right inline with what you guys are teaching here. Should help newcomers acquire a visual.


was8bit 2020-02-05 23:31

Thanks for sharing the youtube line.. very cool info :)

.. and, nope, not me... just a similar name ... i WAS an old school programmer (apple2e, hp15c, etc) but have since upgraded ;) i just chose 8bit to represent old school computers... hence, was8bit ...


Log in to reply.