6502 Newbie / First Game Prototype

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Oziphantom
Posts: 1669
Joined: Tue Feb 07, 2017 2:03 am

Re: 6502 Newbie / First Game Prototype

Post by Oziphantom »

tokumaru wrote: Wed Sep 04, 2024 8:13 pm
Oziphantom wrote: Wed Sep 04, 2024 11:06 amFor entities you can do a "compacted array" as the order of update doesn't usually matter. so what you do is you keep an index of which is the last one, and then when you remove an entity you copy the last data into the slot you are removing and then decrement your "last entity" counter.
That's an interesting idea, but as games get more complex, I think it's more likely that the order of updates will matter (e.g. a moving platform may need to be updated before entities that are riding it), and that entities will reference others via their slot indices (e.g. objects being carried, multi-segmented objects, etc.), so I wouldn't recommend this approach.
sure, what your game is and what your needs are greatly effect how your engine needs to be built.
For example if I'm making a shoot-em-up that is vertical or horizontal scrolling, then I would make the entities a circular buffer and just disable dead entities as they are going to be moving left to right/right to left/up to down/down to up etc for the entire level and there will be a lot of them, that spawn and die fast.

For things like forced update order I generally prefer to make it explicit, but then I usually design for machines with 64K(+) of RAM, it would be less practical on a 2K system.

For player carrying I would make the world and held entities be different, so the world get removed and then a held gets made but it is owned and updated by the player and is not in the entity list. But again stylistic choice/what does a carried object need to do in your game.
User avatar
NEStor
Posts: 4
Joined: Fri Aug 30, 2024 12:35 am
Location: Germany

Re: 6502 Newbie / First Game Prototype

Post by NEStor »

As my entity system is working I spent time Today to made a little progress with the player actions.
I can now initiate a sword entity and let it draw at the players y and x pos, offset by a value depending on the players direction to position it correctly above/below/left/right at the player.

Therefore I created constants for direction, and a global variable for players direction.
In the subroutine for the player update, I set the player direction depending on the direction buttons (button up = sets direction up and so on) and depending on the player direction I draw a different sword sprite (vertical/horizontal).

From a gameplay perspective I tried to get a similar „feeling“ as in Zelda 1.
I made global variable for playerState, and set it to attack when pressing A (sword attack).
In the update player routine I prevent then to move the player around.

The most difficult part for Me was too remove the sword after a short time, and set the player state back to idle state.
I solved it currently by creating a variable AttackTimer, which I set to a specific value when „initiating“ the sword by pressing A button, and decrementing the timer within the update entities subroutine (when it finds an entity of type sword).
As soon as the timer reaches 1 it will remove the sword entity and set the player state from attack to idle.

So I can now not move while attacking, and I have to wait until the timer is down, to do another sword swing.
Found a value which feels about right.

Next thing I would like to accomplish now is sprite animations for the player so that sprite is changing when he is walking (up/down/left/right), animation for attacking (up,down,left,right) and animation for the one monster I have.

I tried also to create an Enemy AI, so that the monster is running around randomly and changing direction if hitting the boundaries of the sceen (if have background collision then it should of course change direction when hitting solid tiles).
But failed to get it work the way I want it.
I didn’t even get it to work so that it just moves to the right until hitting the boundary and then moving left
Until hitting boundary on the left screen side and looping between leftmost/rightmost screen position.
Post Reply