It is currently Fri Oct 19, 2018 10:16 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sun Sep 30, 2018 5:01 pm 
Offline

Joined: Sun Sep 30, 2018 4:47 pm
Posts: 2
Hello, I am extremely new to NES development, although I've had experience in game development for some time using simple programs such as Fusion 2.5. I discovered NESDoug's examples/tutorials, which show how to program for NES using C. C is much more approachable to me than assembly, which I barely could grasp the basics of, hahah. Well, I started building off of the sprites example he posted here, and started to implement a shooting script.

Initially, I couldn't get more than 1 bullet to fire, but I eventually got it to the point where multiple instances could exist, but at the cost of every other sprite disappearing. I can still move the player around, and shoot as many bullets as possible (64 is my implemented limit), but cannot see the player whatsoever. Here is how it looks and here is the code. If anyone is willing to assist, and is in need of more files pertaining to this development, I'll be happy to provide. Thank you for reading this, and hopefully you can help me ;-)


Attachments:
File comment: I've also included the complete source if needed
src.7z [26.04 KiB]
Downloaded 6 times


Last edited by skullkid2802 on Mon Oct 01, 2018 1:48 pm, edited 1 time in total.
Top
 Profile  
 
PostPosted: Sun Sep 30, 2018 5:28 pm 
Offline
User avatar

Joined: Thu Aug 13, 2015 4:40 pm
Posts: 297
Location: Rio de Janeiro - Brazil
The NES draws scanlines (horizontal lines of pixels) to complete the entire screen. Each scanline's pixels are drawn from left to right, and it will only draw 8 sprites. After that for that scanline it will ignore the sprites and draw only the nametable/background color. On the next scanline it will reset this counter. What this means is the NES won't draw many sprites that are on the same horizontal line.

So, your options are to program a flickering system (recommended) and/or rethink your game design.

And if that is not the problem then you are overwriting the memory addresses containing the player sprite information when you create shots. You can hard code addresses, or you can create an object/sprite manager with an object queue. There must be a tutorial for this somewhere.

_________________
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!


Top
 Profile  
 
PostPosted: Sun Sep 30, 2018 6:42 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 2305
Location: DIGDUG
if (b1index>0){

as soon as any value is in b1index it does this...

for(index=0;index<64;index++){
sprid = oam_spr(bullet_x[index], bullet_y[index], 0, 0, sprid);
...
}

and always writes every object in the array to the Sprite buffer. All 64.

The Sprite buffer (OAM) can only hold 64 items, so it's overwriting the other items. ie, looping past the end of the buffer and back into the beginning of the buffer.

Reduce the number of objects.

Only draw them if they are active.

BTW. I sent you an email earlier.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sun Sep 30, 2018 7:53 pm 
Offline

Joined: Sun Sep 30, 2018 4:47 pm
Posts: 2
It works beautifully now! I first saw your email NESdoug, which pretty much helped me out through fixing the whole thing, so I thank you again for this. Here is a video if anyone is interested in seeing the progress. And also, how should I mark this thread as "solved", I'm (obviously) new to these forums.


Top
 Profile  
 
PostPosted: Mon Oct 01, 2018 8:20 am 
Offline
User avatar

Joined: Thu Aug 13, 2015 4:40 pm
Posts: 297
Location: Rio de Janeiro - Brazil
Nice, so it was overwriting :) Dougeff rocks.

I don't recall anyone closing an issue here, there's more of like a topics of discussion mentality. That said, you can edit the title of the original post to add a "[Solved]" to it. There's an edit button to the bottom right of your posts.

_________________
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group