Ejemplo n.º 1
0
void place_sprite(sprite_t *s, camera_t *c) {
	bool exist = s->obj != NULL;
	int screen_x = SCREEN_X(*s, *c);
	int screen_y = SCREEN_Y(*s, *c);
	
	ENGINE_DEBUGFMT("sprite in world at %d, %d on screen at %d, %d, exist: %d, height: %d", s->x, s->height, screen_x, screen_y, exist, SPRITE_HEIGHT(*s));
	
	if ((screen_y + SPRITE_HEIGHT(*s) < 0) ||
	    (screen_y > SCREEN_HEIGHT) ||
	    (screen_x + SPRITE_WIDTH(*s) < 0) ||
	    (screen_x > SCREEN_WIDTH)) {
		if (exist) {
			ENGINE_DEBUG("sprite left! deleting it");
			delete_sprite(s);
		}
		return;
	} else {
		if (!exist) {
			ENGINE_DEBUG("sprite on screen and needs to be created");
			s->obj = new_obj();
		}
	}
	obj_set_attr(s->obj,
	             s->shape | ATTR0_REG,
	             s->size,
	             ATTR2_PALBANK(s->palbank) | s->tile);
	obj_set_pos(s->obj, screen_x, screen_y);
}
Ejemplo n.º 2
0
struct oattr *
obj_set_attr_num(struct odes *o, uns a, uns v)
{
  byte x[32];

  sprintf(x, "%d", v);
  return obj_set_attr(o, a, x);
}
Ejemplo n.º 3
0
void reset_sprites() {
	int i=0;
	for (i=0; i<128; i++) {
		obj_set_attr(&obj_buffer[i],
			ATTR0_TALL | ATTR0_8BPP | ATTR0_HIDE,
			ATTR1_SIZE_16x32,
			ATTR2_PALBANK(0)
		);	
	}
}
Ejemplo n.º 4
0
void init_olimar(OLIMAR* o)
{
   o->bb = { 30,30,16,24 };
   o->hp = 10;
   o->update = update_olimar;
   o->animate = animate_olimar;
   o->coll_cache = { 0,0,0 };
   
   
   
   obj_set_attr(o->obj_buf, 
	             ATTR0_TALL, 
	             ATTR1_SIZE_32x64, 
	             ATTR2_PALBANK(0) | 0);
	             
	pkm->attr0 |= ATTR0_4BPP;
}
Ejemplo n.º 5
0
void init_game()
{
   //Initialization
   
   //Field_0
   memcpy(pal_bg_mem, bd_forestPal, bd_forestPalLen);
   memcpy(&tile_mem[0][0], bd_forestTiles, bd_forestTilesLen);
   memcpy(&se_mem[30][0], bd_forestMap, bd_forestMapLen);
   
   REG_BG0CNT = BG_CBB(0) | BG_SBB(30) | BG_4BPP | BG_REG_32x32 | BG_PRIO(1);
   
   //Bg_Forest
   memcpy(&pal_bg_bank[1], bg_forestPal, bg_forestPalLen);
   memcpy(&tile_mem[0][16], bg_forestTiles, bg_forestTilesLen);
   memcpy(&se_mem[28][0], bg_forestMap, bg_forestMapLen);
   
   REG_BG1CNT = BG_CBB(0) | BG_SBB(28) | BG_4BPP | BG_REG_64x32 | BG_PRIO(0);
   
   
   memcpy(&tile8_mem[4][0], pikmin_sheetTiles, pikmin_sheetTilesLen);
   memcpy(pal_obj_mem, pikmin_sheetPal, pikmin_sheetPalLen);
	
	
	REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_BG1 | DCNT_OBJ| DCNT_OBJ_1D;
	
	oam_init(obj_buffer, 128);
	
	u32 tid=0, pb=0;
	
	OBJ_ATTR *pkm = &obj_buffer[0];
	
	obj_set_attr(pkm, 
	             ATTR0_TALL, 
	             ATTR1_SIZE_16x32, 
	             ATTR2_PALBANK(pb) | tid);
	             
	pkm->attr0 |= ATTR0_8BPP;
	
	oam_copy(oam_mem, obj_buffer, 1);
}