Skip navigation
Welcome, Guest! Please Login or Join

Loading...

Game Engine Building #1: Sprite Movement, Animation, and Meta Sprites NintendoAge Programming Resources

Sep 21, 2015 at 2:02:50 PM
Cockroachcharlie (0)
avatar
< Cherub >
Posts: 19 - Joined: 09/05/2015
Pennsylvania
Profile
Originally posted by: user

Originally posted by: Cockroachcharlie

Lol. Between you and bunnyboy, it's fun comparing your different ramblings. You both make better sense on different topics (which is why I advocate soaking in all knowledge banks possible).

I'm sure it is ridiculously easyand i just keep missing it.

On another note, probably another easy question. Why do the offsets for each metasprite increase by ten when the metasprites themselves are four apiece. I assume this has to do with the total memory of each.
16px wide == 10 in HEX

Hope this helps.

 





... ..... ....... .........I feel really dumb now. :-)

Sep 21, 2015 at 2:03:18 PM
Cockroachcharlie (0)
avatar
< Cherub >
Posts: 19 - Joined: 09/05/2015
Pennsylvania
Profile
edit: double post


Edited: 09/21/2015 at 02:07 PM by Cockroachcharlie

Sep 21, 2015 at 3:28:58 PM
Mega Mario Man (58)
avatar
(Tim ) < Kraid Killer >
Posts: 2288 - Joined: 02/13/2014
Nebraska
Profile
Originally posted by: Cockroachcharlie
 
Originally posted by: Mega Mario Man

So, I studied on this pretty hard the other day and understand the code pretty decent now. If interested, I have editted the original code to work with 2 wide x 4 tall sprites as well with a sprite that I drew. Good stuff, and I think I will try to use meta-sprites in my next game.
I would be very much interested myself in knowing how you did that.  I have been staring at the code and, while I have (i think) a fairly good understanding of what I am seeing, this is one spot where I am just missing.  Can't seem to figure out, where, exactly, he defines the "boundaries" for his meta-sprites.

I have managed to tweak a number of things, I have added more characters to the screen, changed their graphics, and removed some, but I can't get a 2x3 sized sprite (my goal before I move on).

 
I post a .zip file tonight with all the code in it. It's been over a year, so I can't really recall everything I done.

First off, I commented out anything that was related to drawing and animating the enemy sprites so I could concentrate on the playable character. I then made my own CHR file with a 2x4 metasprite character for the testing. I then studyied the code and found where to make the changes and got it all working.

Basically, you are going to have to compare the code to MRN's to see what I changed. Been a long time since I have sat down and wrote some code or read the tutorials. I will try to help where I can if you have questions.

 

-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter

Sep 21, 2015 at 6:00:13 PM
Mega Mario Man (58)
avatar
(Tim ) < Kraid Killer >
Posts: 2288 - Joined: 02/13/2014
Nebraska
Profile
Here is the code.

-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter

Sep 21, 2015 at 6:39:33 PM
user (6)

< El Ripper >
Posts: 1462 - Joined: 05/30/2014
Profile
Originally posted by: Cockroachcharlie
 
Originally posted by: user
 
Originally posted by: Cockroachcharlie

Why do the offsets for each metasprite increase by ten when the metasprites themselves are four apiece. I assume this has to do with the total memory of each.
16px wide == 10 in HEX

Hope this helps.
... ..... ....... .........I feel really dumb now. :-)

You should not.

Actually, my answer is correct, but it was the answer to another question.
In the X position of two metasprites 16x16px next to eachother, the offset is 16px, hance 10 in HEX.
In the Y position of two metasprites 16x16px adjacent vertically, the offset is 16px, hance 10 in HEX.

However, this was not the offset you were asking about.

Still, it is an offset of 16, which is 10 HEX.

Let say that, as the MRN article proposes, you use RAM page $0200 for sprites.

Each metasprite is made of four (4) 8x8px sprites: UpL UpR BottomL BottomR.

Each of these four (4) sprites has four (4) bytes of info:
1. (address +0) Y position
2. (address +1) pattern
3. (address +2) attributes
4. (address +3) X position
Let say the metasprite "Foo" starts at address $0200, and is composed by the following four (4) 8x8px sprites: spriteUL, sprite UR, sprite BL, sprite BR.

$0200 = Y position spriteUL
$0201 = pattern spriteUL
$0202 = attributes spriteUL
$0203 = X position spriteUL

$0204 = Y position spriteUR $0205 = pattern spriteUR $0206 = attributes spriteUR $0207 = X position spriteUR

$0208 = Y position spriteBL $0209 = pattern spriteBL $020a = attributes spriteBL $020b = X position spriteBL

$020c = Y position spriteBR $020d = pattern spriteBR $020e = attributes spriteBR $020f = X position spriteBR
As you can see, there are (4x4) 16 Bytes of info (from RAM address $0200 to $020f, both included) describing the 16x16px metasprite "Foo".

Where the next metasprite will start? At address $0210, with an offset of 16 Bytes, HEX 10, from address $0200.

I think now that this is the offset you were referring to in your question.

My apologies for giving a quick answer without understanding what the question was about, I hope this helps some more.

By the way, if you wonder:
 - There are 256 Bytes to store sprites data.
 - Which makes 64 total (8x8px) sprites (four (4) Bytes each sprite: Yposition, pattern, attributes, X position).
 - Which makes 16 total (16x16px) metasprites available, if your game uses only 16x16 pixel metasprites (four (4) 8x8px sprites are used for each metasprite, hence 64/4).

Also (and sorry for my lacks in English) I hope this answer is correct, makes sense and is understandable.

And if by now you had everything understood already, sorry for the redundancy of this further reply.

Edit: formatting.


Edited: 09/21/2015 at 06:44 PM by user

Oct 25, 2016 at 12:45:45 AM
ubuntuyou (0)
avatar
(Joe ) < Cherub >
Posts: 14 - Joined: 10/24/2016
Nebraska
Profile
Is the attachment for this still available? I'm not seeing a link anywhere. :/

Oct 25, 2016 at 1:05:38 AM
KHAN Games (88)
avatar
(Kevin Hanley) < Master Higgins >
Posts: 7784 - Joined: 06/21/2007
Florida
Profile
Originally posted by: ubuntuyou

Is the attachment for this still available? I'm not seeing a link anywhere. :/

Directly beneath the first post. But above the second post. The attachments are hard to see.  
 

Oct 25, 2016 at 5:47:16 AM
ubuntuyou (0)
avatar
(Joe ) < Cherub >
Posts: 14 - Joined: 10/24/2016
Nebraska
Profile
I see it now. Thank you.  

Aug 22 at 2:38:49 AM
klr128 (0)

< Cherub >
Posts: 1 - Joined: 08/21/2017
Profile
@Mario's Right Nut nice work! thx

Aug 22 at 3:49:56 AM
SoleGooseProductions (120)
avatar
(Beau ) < Ridley Wrangler >
Posts: 2783 - Joined: 04/22/2013
Indiana
Profile
These are some great tutorials to check out once you finish the NN, that is for sure  .

-------------------------
"The light that burns twice as bright burns half as long..." ~ Blade Runner

SoleGooseProductions.com


Sep 22 at 12:12:17 AM
brilliancenp (0)
avatar
(Nick Pruitt) < Tourian Tourist >
Posts: 34 - Joined: 08/15/2017
Kansas
Profile
I have to say that this tutorial is teaching me a ton. Before someone told me about this in another post, I had finished the awesome NN tutorials and had made a program with a player character and all of its animations and movements and controls. It worked but it was ALOT of code. I have been working on the code in this tutorial for 3 days now, trying to understand all of it. As I understand it more and work it into my own program the code is getting so much smaller and concise. Thank you! I look forward to the next one.

Sep 22 at 8:06:06 AM
Mega Mario Man (58)
avatar
(Tim ) < Kraid Killer >
Posts: 2288 - Joined: 02/13/2014
Nebraska
Profile
Originally posted by: brilliancenp

I have to say that this tutorial is teaching me a ton. Before someone told me about this in another post, I had finished the awesome NN tutorials and had made a program with a player character and all of its animations and movements and controls. It worked but it was ALOT of code. I have been working on the code in this tutorial for 3 days now, trying to understand all of it. As I understand it more and work it into my own program the code is getting so much smaller and concise. Thank you! I look forward to the next one.
I feel this tutorial and tutorial #2 are a must after the NN tutorials. The others are great as well, but I feel these first 2 can point you in the proper direction. I use MRN's game engine in my games. I have not devled in the metasprites yet. Maybe someday, but it my next game, I will be loading my sprites in a way that metasprites aren't very helpful.

 

-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter


Edited: 10/05/2017 at 12:55 PM by Mega Mario Man

Oct 05 at 11:37:08 AM
brilliancenp (0)
avatar
(Nick Pruitt) < Tourian Tourist >
Posts: 34 - Joined: 08/15/2017
Kansas
Profile
So I think I fully understand this first tutorial now. I have redesigned my previous program to use it and is so much easier to understand. The one thing I cant seem to figure out is where the striped background is set? I would like to set it to just black for now. Where would I find where he is setting the background?

Oct 05 at 12:55:14 PM
Mega Mario Man (58)
avatar
(Tim ) < Kraid Killer >
Posts: 2288 - Joined: 02/13/2014
Nebraska
Profile
Originally posted by: brilliancenp

So I think I fully understand this first tutorial now. I have redesigned my previous program to use it and is so much easier to understand. The one thing I cant seem to figure out is where the striped background is set? I would like to set it to just black for now. Where would I find where he is setting the background?
Right now, there is no BG loading routine in that code.
You will first have to create and add a BG CHR file to the code (look at how Sprite_Data: section looks). Then load that chr file into the PPU (look at the LoadCompleteBank routine, right now it is just load the Sprite_Data). I would go back to the Nerdy Nights Background tutorials to see how he loads BG data into the PPU to get your new file up to speed.

In Nerdy Nights, all CHR files were 8kb since it held 256 sprite tiles and 256 background tiles. In this tutorial, the sprite CHR file is only 4kb because it only has the 256 sprite tiles. You will need a 4kb BG CHR file for BG tiles. Storing BG and Sprites in separate CHR files is very helpful down the road when you start bankswitching and needing more that 256 BG or Sprite tiles. Then you can swap out BG tiles but keep your sprite tiles or vice versa. You can create 4kb (or even othe sizes!) chr files in NES Screen Tool by going to the Patterns Menu and then selecting the Save CHR drop-down menu.

I hope this helps. This was a huge revalation for me when I finally figured out that you can split and load CHR data in chunks instead of 8kb at a time.

 

-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter

Oct 05 at 2:36:33 PM
brilliancenp (0)
avatar
(Nick Pruitt) < Tourian Tourist >
Posts: 34 - Joined: 08/15/2017
Kansas
Profile
Yes! I took me a couple of days to figure out why my code wouldn't work when I put my chr in instead of his. He had only allocated 4 and mine was 8. I understand bg tiles and such just don't understand how he is accomplishing the black and grey stripes for the bg.

Oct 05 at 3:39:40 PM
Mega Mario Man (58)
avatar
(Tim ) < Kraid Killer >
Posts: 2288 - Joined: 02/13/2014
Nebraska
Profile
He didn't do that. Those are just the default values that are populating that area in the PPU and you are just seeing the result on the screen. Maybe someone more technical than I can tell you exactly why tile $00 is half black and half gray. But, nothing in the code suggests that he meant for it to do that from what I can tell.

-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter


Edited: 10/05/2017 at 03:39 PM by Mega Mario Man

Oct 05 at 3:48:55 PM
SoleGooseProductions (120)
avatar
(Beau ) < Ridley Wrangler >
Posts: 2783 - Joined: 04/22/2013
Indiana
Profile
That's why I skipped to Week 5, and got back to sprites years later  .

-------------------------
"The light that burns twice as bright burns half as long..." ~ Blade Runner

SoleGooseProductions.com


Oct 05 at 7:02:47 PM
brilliancenp (0)
avatar
(Nick Pruitt) < Tourian Tourist >
Posts: 34 - Joined: 08/15/2017
Kansas
Profile
ok thanks, I thought I was just crazy lol. Thanks for the help. I wont mind them for now. I was just trying to understand everything I could.

Thanks again.

Oct 05 at 7:05:14 PM
SoleGooseProductions (120)
avatar
(Beau ) < Ridley Wrangler >
Posts: 2783 - Joined: 04/22/2013
Indiana
Profile
It is a deep lesson, that is for sure!

-------------------------
"The light that burns twice as bright burns half as long..." ~ Blade Runner

SoleGooseProductions.com