Jump to content

mr_woggle

New Members
  • Posts

    3
  • Joined

  • Last visited

mr_woggle's Achievements

Combat Commando

Combat Commando (1/9)

0

Reputation

  1. Thanks for the suggestion. I did not think this through at all, I just thought allocating and freeing 'actors' would be the way to go. Can you explain this a bit more? I guess you mean that you just change the vpos and hpos or something? And keep an array of that, instead of creating many SCB instances? (note: the bomb snippet I use here is just a trivial example to illustrate of the trouble I'm having).
  2. It's something along these lines: sprite_bomb *bombs = 0; void create_bomb() { sprite_bomb * prev = 0, *current = bombs; sprite_bomb * bomb = (sprite_bomb*)malloc(sizeof(sprite_bomb)); create_sprite(bomb); bomb->sprite.hpos = 10; bomb->sprite.vpos = 10; if(bombs != 0){ while(current != 0){ prev = current; current = current->next; } prev->next = bomb; } else { bombs = bomb; } bomb->next = 0; } void create_sprite(sprite_bomb* shot){ shot->sprite.sprctl0 = BPP_1 | TYPE_NORMAL; shot->sprite.sprctl1 = REHV; shot->sprite.sprcoll = 4; shot->sprite.data = singlepixel_data; shot->sprite.hsize = 0x0100; shot->sprite.vsize = 0x0100; } and then in the main loop I draw somewhere: sprite_bomb * bomb = bombs; while(bomb != 0){ tgi_sprite(&(bomb->sprite)); bomb->sprite.vpos += SPEED; bomb = bomb->next; }
  3. I've been programming for the Atari Lynx for a little while. It's fun, but I run into a small problem. I want to dynamically allocate and free collision sprites. I'm aware that the collision offset is -1 relatively to the sprite. My collision sprite type is defined as follows typedef struct { char collindex; SCB_REHV sprite; void *next; } sprite_t; This all goes well, when all the sprites are statically allocated and I set tgi_setcollisiondetection(1); It also goes well if I dynamically allocated the sprites (simple linked list) and tgi_setcollisiondetection(0); Once I set collision detection on, however, it doesn't seem to work. Is this some memory alignment issue or how the heap allocates? Is there any boiler plate code for this? Sincerely, Rob
×
×
  • Create New...