Documentation - gamificalostudio/Tankerfield GitHub Wiki
Documentation : Guide
How to code for the Tankerfield project.
Object class
Creating objects
Point curr_tex
to the texture you want to draw from.
Point curr_anim.frames
to the animation you want to draw.
You won't need to override the PostUpdate, it will use the values you've provided.
bool Object::PostUpdate(float dt, Camera * camera)
{
fPoint screen_pos = app->map->MapToScreenF(pos_map);
app->render->Blit(
curr_tex,
screen_pos.x - draw_offset.x,
screen_pos.y - draw_offset.y,
camera,
&curr_anim->GetFrame(angle));
return true;
}
You can also specify the iPoint draw_offset
to change where the texture is drawn.
IMPORTANT: Animation * curr_anim
is involved in sprite sorting and camera culling processes. If you don't set it, the object will not be drawn.
Weapons
To create a new weapon you must:
-
Define its properties in Obj_Tank::SetWeapon() method
-
Create a new case in
enum class WEAPON
//Obj_Tank.h
enum class WEAPON
{
BASIC,
MAX
};
- Define the shoot effect of the weapon in a new function called Shoot"NameOfTheWeapon"() inside Obj_Tank
//Obj_Tank.cpp
void Obj_Tank::ShootBasic()
{
Obj_Bullet * bullet = (Obj_Bullet*)app->objectmanager->CreateObject(ObjectType::BASIC_BULLET, turr_pos + shot_dir * cannon_length);
bullet->SetBulletProperties(
weapons_info[(uint)basic_shot].bullet_speed,
weapons_info[(uint)basic_shot].bullet_life_ms,
weapons_info[(uint)basic_shot].bullet_damage,
shot_dir,
turr_angle);
}
- Fill the corresponding position in the functions pointer array
//Obj_Tank.cpp
bool Obj_Tank::Start()
{
shot_function[(uint)WEAPON::BASIC] = &Obj_Tank::ShootBasic;
return true;
}