Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: chickendude on June 05, 2012, 02:10:20 pm

Title: Enemies and objects
Post by: chickendude on June 05, 2012, 02:10:20 pm
Currently what i do is just load a list of enemies when i go to load the map and run through and update the entire list each frame. Really it doesn't take so long and even with maybe 20 enemies the slow-down isn't that noticeable, but i think i will probably just build them into the map so that they are triggered when you reach a certain tile. I'm not sure how large the final levels will be. Anyway it wouldn't be too difficult to do, i've just been lazy and not really sure if there are better ways to do it.

I've also never done enemy routing/paths, will i need to touch any trig? Right now the enemies just kinda fly around and bounce off the walls, which i think is pretty interesting and a little funny even but maybe not so practical for the final game.

I guess it's not really anything i desperately need help with as most of the code's already written, but it'd be fun to talk about something here and hear your ideas (and not just ASM programmers, since i imagine the concept would be basically the same), i learned a lot from the old tilemap discussions over at RevSoft and MC.
Title: Re: Enemies and objects
Post by: aeTIos on June 05, 2012, 02:28:36 pm
Maybe this could better be moved to a more general forum?
Title: Re: Enemies and objects
Post by: LincolnB on June 05, 2012, 04:11:39 pm
what kind of discussion are you trying to start?
Title: Re: Enemies and objects
Post by: aeTIos on June 05, 2012, 04:13:46 pm
He wants to discuss any ways to code enemies and objects.
Title: Re: Enemies and objects
Post by: LincolnB on June 05, 2012, 04:17:04 pm
Personally, I have a set of subroutines like CreateEnemy(), KillEnemy() which add to/subtract from the list of enemies (stored in free ram wherever), and some stuff with MoveEnemy, SimEnemies(), which runs through the list and moves the enemies however I defined it. And collisions and whatnot
Title: Re: Enemies and objects
Post by: chickendude on June 06, 2012, 01:21:04 am
Well, right now i've got my data set up like this:
Code: [Select]
;ENEMY EQUATES (pour utiliser avec ix)
MECHANT_SPRITE = 0
MECHANT_X = 1
MECHANT_XOFF = 2
MECHANT_Y = 3
MECHANT_YOFF = 4
MECHANT_XVEL = 5
MECHANT_YVEL = 6
MECHANT_HP = 7

MECHANT_SIZE = 8
liste_de_mechants:
; .db # sprite, mechantX, mechantXOff, mechantY, mechantYOff, xVel, yVel, HP
; m1 S X XO Y YO XV YV HP
.db $5, 12, 0, 7, 0, 0, 0, 1
; m2
.db $0, 6, 2, 4, 0, -1, 1, 1
; m3
.db $0, 4, 3, 3, 1, -3, 1, 1 ; carré
; m4
.db $4, 7, 4, 4, 1, -1, -1, 1 ; sorte d'oeil
; m5
.db $0, 6, 5, 4, 4, 0, 2, 5
nombreMechants:
.db 5
...and modify those values each frame. I realize that if i add in a lot of enemies later on, loading them all at once will slow the game down quite a bit (though it'd have to be a LOT of enemies). When an enemy is killed, i just shift all enemies below it up one. Basically, i'm curious how you store and process your data, for example whether it's worthwhile to keep track of offscreen enemies or remove them from the list. I think giving the map the ability to create (spawn) enemies would make the map routine much more powerful would give you code to easily reuse in other places, for example if you want a boss to be able to toss out enemies at you or something.
Title: Re: Enemies and objects
Post by: tr1p1ea on June 14, 2012, 05:10:28 am
If you move around in your game screen-by-screen then you could possibly think about having another list that simply hold the 'index' of any onscreen objects in your list.

Apart from that you could look at some 'early exit' techniques for ignoring offscreen objects when looping through?
Title: Re: Enemies and objects
Post by: chickendude on June 14, 2012, 06:22:50 am
Well, when a level is loaded the entire level is loaded. I could set a certain distance to remove (delete) an object from the list, as i've never really liked resetting enemies back to their original positions when they go offscreen. I remember you talking to me about how you had objects and enemies set up in Super Mario a couple years back, maybe over at RevSoft?