Author Topic: Enemies and objects  (Read 2797 times)

0 Members and 1 Guest are viewing this topic.

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Enemies and objects
« 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.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Enemies and objects
« Reply #1 on: June 05, 2012, 02:28:36 pm »
Maybe this could better be moved to a more general forum?
I'm not a nerd but I pretend:

Offline LincolnB

  • Check It Out Now
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1115
  • Rating: +125/-4
  • By Hackers For Hackers
    • View Profile
Re: Enemies and objects
« Reply #2 on: June 05, 2012, 04:11:39 pm »
what kind of discussion are you trying to start?
Completed Projects:
   >> Spacky Emprise   >> Spacky 2 - Beta   >> Fantastic Sam
   >> An Exercise In Futility   >> GeoCore

My Current Projects:

Projects in Development:
In Medias Res - Contest Entry

Talk to me if you need help with Axe coding.


Spoiler For Bragging Rights:
Not much yet, hopefully this section will grow soon with time (and more contests)



Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Enemies and objects
« Reply #3 on: June 05, 2012, 04:13:46 pm »
He wants to discuss any ways to code enemies and objects.
I'm not a nerd but I pretend:

Offline LincolnB

  • Check It Out Now
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1115
  • Rating: +125/-4
  • By Hackers For Hackers
    • View Profile
Re: Enemies and objects
« Reply #4 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
Completed Projects:
   >> Spacky Emprise   >> Spacky 2 - Beta   >> Fantastic Sam
   >> An Exercise In Futility   >> GeoCore

My Current Projects:

Projects in Development:
In Medias Res - Contest Entry

Talk to me if you need help with Axe coding.


Spoiler For Bragging Rights:
Not much yet, hopefully this section will grow soon with time (and more contests)



Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Enemies and objects
« Reply #5 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.

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: Enemies and objects
« Reply #6 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?
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."


Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Enemies and objects
« Reply #7 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?