bool Background::init() { //We need to create an orthographic camera camera_id_ = manager_->window->new_camera(); update_camera(Viewport()); //FIXME: Only fullscreen?? //Create a stage to add to the render pipeline stage_id_ = manager_->window->new_stage(PARTITIONER_NULL); { auto stage = manager_->window->stage(stage_id_); actor_id_ = stage->new_actor(); //Load the background material material_id_ = stage->assets->new_material_from_file(Material::BuiltIns::TEXTURE_ONLY); auto mesh = stage->assets->new_mesh_as_rectangle(1, 1, Vec2(0.5, 0.5)); stage->actor(actor_id_)->set_mesh(mesh); stage->assets->mesh(mesh)->set_material_id(material_id_); } //Add a pass for this background pipeline_id_ = manager_->window->render(stage_id_, camera_id_).with_priority( smlt::RENDER_PRIORITY_BACKGROUND + manager_->background_count() ); return true; }
Actor* actor_addJoueur(GList *actList, TreeNode *root, int x, int y) { Actor *act; act = new_actor(); act->pos_x = x; act->pos_y = y; act->vit_x = 0; act->vit_y = 0; act->direction_regard = 0; act->sprite[ETAT_REPOS][0] = sprite_joueur[ETAT_REPOS][0]; act->sprite[ETAT_REPOS][1] = sprite_joueur[ETAT_REPOS][1]; act->sprite[ETAT_REPOS][2] = sprite_joueur[ETAT_REPOS][2]; act->sprite[ETAT_REPOS][3] = sprite_joueur[ETAT_REPOS][3]; act->sprite[ETAT_MARCHE][0] = sprite_joueur[ETAT_MARCHE][0]; act->sprite[ETAT_MARCHE][1] = sprite_joueur[ETAT_MARCHE][1]; act->sprite[ETAT_MARCHE][2] = sprite_joueur[ETAT_MARCHE][2]; act->sprite[ETAT_MARCHE][3] = sprite_joueur[ETAT_MARCHE][3]; act->w = sprite_monster->frames[0]->w; act->h = sprite_monster->frames[0]->h; act->vie = 3; act->att_puissance = 1; act->type = ACT_JOUEUR; tree_addActor(root, act, 1); glist_addCell(actList, act); return act; }
void actor_addTree(GList *actList, TreeNode *root, int x, int y) { Actor *act; act = new_actor(); act->pos_x = x; act->pos_y = y; act->vit_x = 0; act->vit_y = 0; act->direction_regard = 0; act->sprite[ETAT_REPOS][0] = sprite_tree; act->sprite[ETAT_REPOS][1] = sprite_tree; act->sprite[ETAT_REPOS][2] = sprite_tree; act->sprite[ETAT_REPOS][3] = sprite_tree; act->w = sprite_tree->frames[0]->w/2; act->h = sprite_tree->frames[0]->h/2; act->vie = 255; act->type = ACT_TREE; tree_addActor(root, act, 0); glist_addCell(actList, act); }
void actor_addMissile(GList *actList, struct TreeNode *root, int x, int y, float vx, float vy) { Actor *act; act = new_actor(); act->pos_x = x; act->pos_y = y; act->vit_x = vx; act->vit_y = vy; act->direction_regard = 0; act->sprite[ETAT_REPOS][0] = sprite_missile; act->sprite[ETAT_REPOS][1] = sprite_missile; act->sprite[ETAT_REPOS][2] = sprite_missile; act->sprite[ETAT_REPOS][3] = sprite_missile; act->w = sprite_monster->frames[0]->w; act->h = sprite_monster->frames[0]->h; act->vie = 2; act->att_puissance = 1; act->type = ACT_MISSILE; tree_addActor(root, act, 1); glist_addCell(actList, act); }
void actor_addMonster(GList *actList, TreeNode *root, int x, int y) { Actor *act; act = new_actor(); act->pos_x = x; act->pos_y = y; act->vit_x = 0; act->vit_y = 0; act->direction_regard = 0; act->sprite[ETAT_REPOS][0] = sprite_monster; act->sprite[ETAT_REPOS][1] = sprite_monster; act->sprite[ETAT_REPOS][2] = sprite_monster; act->sprite[ETAT_REPOS][3] = sprite_monster; act->w = sprite_monster->frames[0]->w; act->h = sprite_monster->frames[0]->h; act->vie = 1; act->att_puissance = 1; act->type = ACT_ENNEMIS; tree_addActor(root, act, 1); glist_addCell(actList, act); }
ActorID Stage::new_actor_with_parent(Actor& parent, MeshID mid) { Actor& ent = actor(new_actor(mid)); ent.set_parent(parent); return ent.id(); }
ActorID Stage::new_actor_with_parent_and_mesh(ActorID parent, MeshID mid) { ActorID new_id = new_actor(mid); actor(new_id)->set_parent(parent); return new_id; }
ActorID Stage::new_actor_with_parent(ActorID parent) { ActorID new_id = new_actor(); actor(new_id)->set_parent(parent); return new_id; }
ActorID Stage::new_actor(MeshID mid) { return new_actor(mid, false, false); }