Limpiar juego de ejemplo
This commit is contained in:
609
Game/GameEnts.c
609
Game/GameEnts.c
@@ -18,50 +18,6 @@ Entity ent_Platform;
|
||||
Entity ent_Block;
|
||||
|
||||
|
||||
DrawImg img_wizard[2];
|
||||
//DrawImg img_wizardWalking[2];
|
||||
//DrawImg img_wizardShoting[2];
|
||||
//DrawImg img_wizardPain[2];
|
||||
DrawImg img_magikball;
|
||||
DrawImg img_earth[16];
|
||||
//DrawImg img_earthBack[16];
|
||||
DrawImg img_stoneBrick;
|
||||
//DrawImg img_stoneBrick[16];
|
||||
//DrawImg img_stoneBrickBack[16];
|
||||
DrawImg img_spikedBush;
|
||||
DrawImg img_lavaPit;
|
||||
DrawImg img_fireball;
|
||||
DrawImg img_flower[2];
|
||||
DrawImg img_spike[2];
|
||||
DrawImg img_carnivorePlant[2];
|
||||
DrawImg img_bunny[2];
|
||||
DrawImg img_spider[2];
|
||||
DrawImg img_guard[2];
|
||||
DrawImg img_eliteGuard[2];
|
||||
DrawImg img_axe[2];
|
||||
DrawImg img_goatMan[2];
|
||||
DrawImg img_Princess[2];
|
||||
|
||||
Entity ent_Wizard;
|
||||
Entity ent_MagikBall;
|
||||
Entity ent_Earth;
|
||||
Entity ent_EarthBack;
|
||||
Entity ent_StoneBrick;
|
||||
Entity ent_StoneBrickBack;
|
||||
Entity ent_SpikedBush;
|
||||
Entity ent_Fireball;
|
||||
Entity ent_LavaPit;
|
||||
Entity ent_Spike[2];
|
||||
Entity ent_Flower[2];
|
||||
Entity ent_CarnivorePlant[2];
|
||||
Entity ent_Bunny;
|
||||
Entity ent_Spider;
|
||||
Entity ent_Axe;
|
||||
Entity ent_Guard;
|
||||
Entity ent_EliteGuard;
|
||||
Entity ent_GoatMan;
|
||||
Entity ent_Princess;
|
||||
|
||||
|
||||
|
||||
int EntityApplyGravity(Entity e){
|
||||
@@ -72,15 +28,6 @@ int EntityApplyGravity(Entity e){
|
||||
// Only apply gravity to some entity types
|
||||
if(!(
|
||||
e->type==Ent_Player ||
|
||||
e->type==Ent_Wizard ||
|
||||
e->type==Ent_Fireball ||
|
||||
e->type==Ent_Bunny ||
|
||||
e->type==Ent_Spider ||
|
||||
e->type==Ent_Axe ||
|
||||
e->type==Ent_Guard ||
|
||||
e->type==Ent_EliteGuard ||
|
||||
e->type==Ent_GoatMan ||
|
||||
e->type==Ent_Princess ||
|
||||
0
|
||||
))
|
||||
{
|
||||
@@ -97,81 +44,8 @@ int EntityApplyGravity(Entity e){
|
||||
|
||||
|
||||
|
||||
void EntEarth_Init(Entity ent,int up,int down,int left,int right){
|
||||
int val=up*8+right*4+down*2+left;
|
||||
|
||||
|
||||
if(!up && !down && !left && !right){
|
||||
ent->flags=0;
|
||||
}else
|
||||
if(up && !down && !left && !right){
|
||||
ent->flags=EntityFlag_PlatformCollision;
|
||||
}else{
|
||||
ent->flags=EntityFlag_BlockCollision;
|
||||
}
|
||||
|
||||
AnimPlay_SetImg(&ent->anim,img_earth[val]);
|
||||
}
|
||||
|
||||
void EntStoneBrick_Init(Entity ent,int up,int down,int left,int right){
|
||||
if(!up && !down && !left && !right){
|
||||
ent->flags=0;
|
||||
}else
|
||||
if(up && !down && !left && !right){
|
||||
ent->flags=EntityFlag_PlatformCollision;
|
||||
}else{
|
||||
ent->flags=EntityFlag_BlockCollision;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void player_proc(Entity e,int ft){
|
||||
float acel=1.0f;
|
||||
float maxVel=4.0f;
|
||||
float jumpVel=12.0f;
|
||||
|
||||
if(Input_GetKey(InputKey_Jump)==InputKey_Pressed ||
|
||||
Input_GetKey(InputKey_Up)==InputKey_Pressed){
|
||||
vec2 jump;
|
||||
|
||||
// Apply jump
|
||||
vec2_set(jump,0.0f,-jumpVel);
|
||||
vec2_plus(e->vel,e->vel,jump);
|
||||
Entity_CalcBBox(e);
|
||||
|
||||
// FIXME: play sound
|
||||
}
|
||||
if(Input_GetKey(InputKey_Left)){
|
||||
vec2 left;
|
||||
|
||||
// Apply left movement
|
||||
vec2_set(left,-acel,0.0f);
|
||||
Entity_AddVelLimit(e,left,maxVel);
|
||||
}
|
||||
if(Input_GetKey(InputKey_Right)){
|
||||
vec2 right;
|
||||
|
||||
// Apply right movement
|
||||
vec2_set(right,acel,0.0f)
|
||||
Entity_AddVelLimit(e,right,maxVel);
|
||||
}
|
||||
|
||||
|
||||
// Scroll View
|
||||
GameLib_MoveToPosH(e->pos,0.1f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void wizard_proc(Entity e,int ft){
|
||||
float acel=8.0f;
|
||||
float maxVel=30.0f;
|
||||
float jumpVel=50.0f;
|
||||
@@ -197,8 +71,6 @@ void wizard_proc(Entity e,int ft){
|
||||
vec2_set(left,-acel,0.0f);
|
||||
Entity_AddVelLimit(e,left,maxVel);
|
||||
|
||||
|
||||
AnimPlay_SetImg(&e->anim,img_wizard[0]);
|
||||
e->A=0;
|
||||
}
|
||||
if(Input_GetKey(InputKey_Right)){
|
||||
@@ -208,248 +80,23 @@ void wizard_proc(Entity e,int ft){
|
||||
vec2_set(right,acel,0.0f)
|
||||
Entity_AddVelLimit(e,right,maxVel);
|
||||
|
||||
AnimPlay_SetImg(&e->anim,img_wizard[1]);
|
||||
|
||||
e->A=1;
|
||||
}
|
||||
if(Input_GetKey(InputKey_Action1)==InputKey_Pressed ||
|
||||
Input_GetKey(InputKey_Action2)==InputKey_Pressed)
|
||||
{
|
||||
Entity e2;
|
||||
|
||||
// Create child entity
|
||||
e2=Entity_Copy(e->child);
|
||||
vec2_plus(e2->pos,e2->pos,e->pos);
|
||||
if(e->A==0){
|
||||
vec2_set(e2->vel,-shootVel,0);
|
||||
}else
|
||||
if(e->A==1){
|
||||
vec2_set(e2->vel,shootVel,0);
|
||||
}
|
||||
Entity_CalcBBox(e2);
|
||||
GameLib_AddEntity(e2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Scroll View
|
||||
GameLib_MoveToPosH(e->pos,0.6f);
|
||||
//GameLib_MoveToPosH(e->pos,0.6f);
|
||||
GameLib_MoveToPos(e->pos,0.6f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int magikball_collision(Entity ent,Entity ent2,float t,vec2 n){
|
||||
if(ent->A==1)
|
||||
return(0);
|
||||
|
||||
if(ent2->type==Ent_Flower){
|
||||
Entity e2;
|
||||
// Convert a flower
|
||||
|
||||
// Create replacemente entity
|
||||
e2=Entity_Copy(ent_CarnivorePlant[ent2->D]);
|
||||
vec2_plus(e2->pos,e2->pos,ent2->pos);
|
||||
GameLib_AddEntity(e2);
|
||||
|
||||
// Delete original entity
|
||||
GameLib_DelEntity(ent2);
|
||||
}
|
||||
if(ent2->type==Ent_Bunny){
|
||||
Entity e2;
|
||||
// Convert a bunny
|
||||
printf("Bunny\n");
|
||||
|
||||
// Create replacemente entity
|
||||
e2=Entity_Copy(ent_Spider);
|
||||
vec2_plus(e2->pos,e2->pos,ent2->pos);
|
||||
GameLib_AddEntity(e2);
|
||||
|
||||
// Copy direction
|
||||
e2->A=ent2->A;
|
||||
|
||||
// Delete original entity
|
||||
GameLib_DelEntity(ent2);
|
||||
}
|
||||
|
||||
// Selfdestroy
|
||||
GameLib_DelEntity(ent);
|
||||
ent->A=1;
|
||||
|
||||
// FIXME: play sound
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
void spikedentity_overlap(Entity e,Entity e2){
|
||||
// FIXME: damage player
|
||||
printf("FIXME: damage player\n");
|
||||
}
|
||||
|
||||
|
||||
int spike_collision(Entity ent,Entity ent2,float t,vec2 n){
|
||||
if(ent->A==1)
|
||||
return(0);
|
||||
|
||||
if(ent2->type==Ent_Player ||
|
||||
ent2->type==Ent_Wizard)
|
||||
{
|
||||
// FIXME: damage player
|
||||
printf("FIXME: damage player\n");
|
||||
}
|
||||
|
||||
// Selfdestroy
|
||||
GameLib_DelEntity(ent);
|
||||
ent->A=1;
|
||||
|
||||
// FIXME: play sound
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
void flower_oncopy(Entity ent){
|
||||
ent->A=rand()%ent->C;
|
||||
}
|
||||
|
||||
void flower_proc(Entity ent,int ft){
|
||||
if(ent->A==0){
|
||||
Entity e2;
|
||||
|
||||
// Create child entity
|
||||
e2=Entity_Copy(ent->child);
|
||||
vec2_plus(e2->pos,e2->pos,ent->pos);
|
||||
GameLib_AddEntity(e2);
|
||||
|
||||
|
||||
// FIXME: play sound
|
||||
|
||||
ent->A=ent->B;
|
||||
}else{
|
||||
ent->A--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void bunny_proc(Entity e,int ft){
|
||||
float acel=1.0f;
|
||||
float maxVel=4.0f;
|
||||
float jumpVel=5.0f;
|
||||
|
||||
if(e->B==0){
|
||||
vec2 jump;
|
||||
|
||||
// Apply jump
|
||||
vec2_set(jump,0.0f,-jumpVel);
|
||||
vec2_plus(e->vel,e->vel,jump);
|
||||
Entity_CalcBBox(e);
|
||||
|
||||
// FIXME: play sound
|
||||
|
||||
e->B=e->C;
|
||||
}else{
|
||||
e->B--;
|
||||
}
|
||||
if(e->A==0){
|
||||
vec2 left;
|
||||
|
||||
// Apply left movement
|
||||
vec2_set(left,-acel,0.0f);
|
||||
Entity_AddVelLimit(e,left,maxVel);
|
||||
|
||||
AnimPlay_SetImg(&e->anim,img_bunny[0]);
|
||||
}
|
||||
if(e->A==1){
|
||||
vec2 right;
|
||||
|
||||
// Apply right movement
|
||||
vec2_set(right,acel,0.0f)
|
||||
Entity_AddVelLimit(e,right,maxVel);
|
||||
|
||||
AnimPlay_SetImg(&e->anim,img_bunny[1]);
|
||||
}
|
||||
}
|
||||
int bunny_collision(Entity ent,Entity ent2,float t,vec2 n){
|
||||
if(n[0]>0.5f){
|
||||
ent->A=1;
|
||||
}else
|
||||
if(n[0]<-0.5f){
|
||||
ent->A=0;
|
||||
}
|
||||
|
||||
|
||||
if(ent2->type==Ent_Player ||
|
||||
ent2->type==Ent_Wizard)
|
||||
{
|
||||
// FIXME: damage player
|
||||
printf("FIXME: damage player\n");
|
||||
}
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void spider_proc(Entity e,int ft){
|
||||
float acel=1.0f;
|
||||
float maxVel=4.0f;
|
||||
float jumpVel=5.0f;
|
||||
|
||||
if(e->B==0){
|
||||
vec2 jump;
|
||||
|
||||
// Apply jump
|
||||
vec2_set(jump,0.0f,-jumpVel);
|
||||
vec2_plus(e->vel,e->vel,jump);
|
||||
Entity_CalcBBox(e);
|
||||
|
||||
// FIXME: play sound
|
||||
|
||||
e->B=e->C;
|
||||
}else{
|
||||
e->B--;
|
||||
}
|
||||
if(e->A==0){
|
||||
vec2 left;
|
||||
|
||||
// Apply left movement
|
||||
vec2_set(left,-acel,0.0f);
|
||||
Entity_AddVelLimit(e,left,maxVel);
|
||||
|
||||
|
||||
AnimPlay_SetImg(&e->anim,img_spider[0]);
|
||||
}
|
||||
if(e->A==1){
|
||||
vec2 right;
|
||||
|
||||
// Apply right movement
|
||||
vec2_set(right,acel,0.0f)
|
||||
Entity_AddVelLimit(e,right,maxVel);
|
||||
|
||||
AnimPlay_SetImg(&e->anim,img_spider[1]);
|
||||
}
|
||||
}
|
||||
int spider_collision(Entity ent,Entity ent2,float t,vec2 n){
|
||||
if(n[0]>0.5f){
|
||||
ent->A=1;
|
||||
}else
|
||||
if(n[0]<-0.5f){
|
||||
ent->A=0;
|
||||
}
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void GameEnts_Init(){
|
||||
|
||||
|
||||
@@ -461,76 +108,6 @@ void GameEnts_Init(){
|
||||
img_platform=Draw_LoadImage("data/platform.png");
|
||||
img_block=Draw_LoadImage("data/block.png");
|
||||
|
||||
// Wizard
|
||||
img_wizard[0]=Draw_LoadImage("data/wizard_left.png");
|
||||
//img_wizard[1]=Draw_LoadImage("data/wizard_right.png");
|
||||
img_wizard[1]=Draw_LoadImage("data/wizard_right.png");
|
||||
|
||||
// Magik Ball
|
||||
img_magikball=Draw_LoadImage("data/magikball.png");
|
||||
|
||||
// Load the earth images
|
||||
img_earth[ 0]=Draw_LoadImage("data/earth/0.png");
|
||||
img_earth[ 1]=Draw_LoadImage("data/earth/1.png");
|
||||
img_earth[ 2]=Draw_LoadImage("data/earth/2.png");
|
||||
img_earth[ 3]=Draw_LoadImage("data/earth/3.png");
|
||||
img_earth[ 4]=Draw_LoadImage("data/earth/4.png");
|
||||
img_earth[ 5]=Draw_LoadImage("data/earth/5.png");
|
||||
img_earth[ 6]=Draw_LoadImage("data/earth/6.png");
|
||||
img_earth[ 7]=Draw_LoadImage("data/earth/7.png");
|
||||
img_earth[ 8]=Draw_LoadImage("data/earth/8.png");
|
||||
img_earth[ 9]=Draw_LoadImage("data/earth/9.png");
|
||||
img_earth[10]=Draw_LoadImage("data/earth/A.png");
|
||||
img_earth[11]=Draw_LoadImage("data/earth/B.png");
|
||||
img_earth[12]=Draw_LoadImage("data/earth/C.png");
|
||||
img_earth[13]=Draw_LoadImage("data/earth/D.png");
|
||||
img_earth[14]=Draw_LoadImage("data/earth/E.png");
|
||||
img_earth[15]=Draw_LoadImage("data/earth/F.png");
|
||||
|
||||
// FIXME: Earth back
|
||||
|
||||
// Stone Brick
|
||||
img_stoneBrick=Draw_LoadImage("data/rock.png");
|
||||
|
||||
// FIXME: Stone Brick back
|
||||
|
||||
// Spiked Bush
|
||||
img_spikedBush=Draw_LoadImage("data/spikedbush.png");
|
||||
|
||||
// FIXME: Lava Pit
|
||||
|
||||
// FIXME: Fireball
|
||||
|
||||
// Flower
|
||||
img_flower[0]=Draw_LoadImage("data/flower_left.png");
|
||||
img_flower[1]=Draw_LoadImage("data/flower_right.png");
|
||||
|
||||
// Spike
|
||||
img_spike[0]=Draw_LoadImage("data/spike_left.png");
|
||||
img_spike[1]=Draw_LoadImage("data/spike_right.png");
|
||||
|
||||
// Carnivore Plant
|
||||
img_carnivorePlant[0]=Draw_LoadImage("data/carnivoreplant_left.png");
|
||||
img_carnivorePlant[1]=Draw_LoadImage("data/carnivoreplant_right.png");
|
||||
|
||||
// Bunny
|
||||
img_bunny[0]=Draw_LoadImage("data/bunny_left.png");
|
||||
img_bunny[1]=Draw_LoadImage("data/bunny_right.png");
|
||||
|
||||
// Spider
|
||||
img_spider[0]=Draw_LoadImage("data/spider_left.png");
|
||||
img_spider[1]=Draw_LoadImage("data/spider_right.png");
|
||||
|
||||
// FIXME: Guard
|
||||
|
||||
// FIXME: Elite Guard
|
||||
|
||||
// FIXEM: Axe
|
||||
|
||||
// FIXME: GoatMan
|
||||
|
||||
// FIXME: Princess
|
||||
|
||||
|
||||
/////////////////////////
|
||||
// Initialize entity types.
|
||||
@@ -575,187 +152,5 @@ void GameEnts_Init(){
|
||||
ent_Block->fric_static=0.0f;
|
||||
ent_Block->fric_dynamic=0.2f;
|
||||
|
||||
|
||||
|
||||
|
||||
// Magik Ball
|
||||
ent_MagikBall=Entity_New();
|
||||
ent_MagikBall->type=Ent_Spike;
|
||||
ent_MagikBall->flags=EntityFlag_Collision;
|
||||
ent_MagikBall->zorder=0;
|
||||
AnimPlay_SetImg(&ent_MagikBall->anim,img_magikball);
|
||||
ent_MagikBall->mass=1.0f;
|
||||
ent_MagikBall->radius=5;
|
||||
ent_MagikBall->width=10;
|
||||
ent_MagikBall->height=10;
|
||||
ent_MagikBall->collision=magikball_collision;
|
||||
|
||||
// Wizard
|
||||
ent_Wizard=Entity_New();
|
||||
ent_Wizard->type=Ent_Wizard;
|
||||
ent_Wizard->flags=EntityFlag_Collision|EntityFlag_Overlap;
|
||||
ent_Wizard->zorder=0;
|
||||
AnimPlay_SetImg(&ent_Wizard->anim,img_wizard[0]);
|
||||
ent_Wizard->proc=wizard_proc;
|
||||
ent_Wizard->mass=1.0f;
|
||||
ent_Wizard->radius=24;
|
||||
ent_Wizard->width=24;
|
||||
ent_Wizard->height=58;
|
||||
ent_Wizard->elast=0.1f;
|
||||
ent_Wizard->fric_static=0.0f;
|
||||
ent_Wizard->fric_dynamic=0.2f;
|
||||
ent_Wizard->child=ent_MagikBall;
|
||||
|
||||
|
||||
|
||||
|
||||
// Earth
|
||||
ent_Earth=Entity_New();
|
||||
ent_Earth->type=Ent_Earth;
|
||||
ent_Earth->flags=EntityFlag_BlockCollision;
|
||||
ent_Earth->zorder=-2;
|
||||
AnimPlay_SetImg(&ent_Earth->anim,img_earth[0]);
|
||||
ent_Earth->mass=0.0f;
|
||||
ent_Earth->radius=16;
|
||||
ent_Earth->width=32;
|
||||
ent_Earth->height=32;
|
||||
ent_Earth->fric_static=0.0f;
|
||||
ent_Earth->fric_dynamic=0.6f;
|
||||
|
||||
|
||||
// FIXME: Earth back
|
||||
|
||||
// Stone Bricks
|
||||
ent_StoneBrick=Entity_New();
|
||||
ent_StoneBrick->type=Ent_StoneBrick;
|
||||
ent_StoneBrick->flags=EntityFlag_BlockCollision;
|
||||
ent_StoneBrick->zorder=-2;
|
||||
AnimPlay_SetImg(&ent_StoneBrick->anim,img_stoneBrick);
|
||||
ent_StoneBrick->mass=0.0f;
|
||||
ent_StoneBrick->radius=16;
|
||||
ent_StoneBrick->width=32;
|
||||
ent_StoneBrick->height=32;
|
||||
ent_StoneBrick->fric_static=0.0f;
|
||||
ent_StoneBrick->fric_dynamic=-0.01f;
|
||||
|
||||
// FIXME: Stone Bricks back
|
||||
|
||||
// Spiked Bush
|
||||
ent_SpikedBush=Entity_New();
|
||||
ent_SpikedBush->type=Ent_SpikedBush;
|
||||
ent_SpikedBush->flags=EntityFlag_Overlap;
|
||||
vec2_set(ent_SpikedBush->pos,0,8);
|
||||
ent_SpikedBush->zorder=1;
|
||||
AnimPlay_SetImg(&ent_SpikedBush->anim,img_spikedBush);
|
||||
ent_SpikedBush->mass=0.0f;
|
||||
ent_SpikedBush->radius=24;
|
||||
ent_SpikedBush->overlap=spikedentity_overlap;
|
||||
|
||||
// FIXME: Fireball
|
||||
|
||||
|
||||
// FIXME: Lava Pit
|
||||
|
||||
|
||||
// Spikes
|
||||
ent_Spike[0]=Entity_New();
|
||||
ent_Spike[0]->type=Ent_Spike;
|
||||
ent_Spike[0]->flags=EntityFlag_Collision;
|
||||
ent_Spike[0]->zorder=0;
|
||||
AnimPlay_SetImg(&ent_Spike[0]->anim,img_spike[0]);
|
||||
vec2_set(ent_Spike[0]->pos,0,-16);
|
||||
ent_Spike[0]->mass=1.0f;
|
||||
ent_Spike[0]->radius=5;
|
||||
ent_Spike[0]->width=10;
|
||||
ent_Spike[0]->height=10;
|
||||
ent_Spike[0]->collision=spike_collision;
|
||||
vec2_set(ent_Spike[0]->vel,-3,2);
|
||||
ent_Spike[1]=Entity_Copy(ent_Spike[0]);
|
||||
AnimPlay_SetImg(&ent_Spike[1]->anim,img_spike[1]);
|
||||
vec2_set(ent_Spike[1]->vel,3,2);
|
||||
|
||||
|
||||
// Flower
|
||||
ent_Flower[0]=Entity_New();
|
||||
ent_Flower[0]->type=Ent_Flower;
|
||||
ent_Flower[0]->flags=EntityFlag_Collision|EntityFlag_Overlap;
|
||||
ent_Flower[0]->zorder=1;
|
||||
AnimPlay_SetImg(&ent_Flower[0]->anim,img_flower[0]);
|
||||
ent_Flower[0]->mass=0.0f;
|
||||
ent_Flower[0]->radius=16;
|
||||
ent_Flower[0]->overlap=spikedentity_overlap;
|
||||
ent_Flower[0]->oncopy=flower_oncopy;
|
||||
ent_Flower[0]->proc=flower_proc;
|
||||
ent_Flower[0]->B=60;
|
||||
ent_Flower[0]->C=60;
|
||||
ent_Flower[0]->child=ent_Spike[0];
|
||||
ent_Flower[0]->D=0;
|
||||
ent_Flower[1]=Entity_Copy(ent_Flower[0]);
|
||||
AnimPlay_SetImg(&ent_Flower[1]->anim,img_flower[1]);
|
||||
ent_Flower[1]->child=ent_Spike[1];
|
||||
ent_Flower[1]->D=1;
|
||||
|
||||
|
||||
// Carnivore Plant
|
||||
ent_CarnivorePlant[0]=Entity_New();
|
||||
ent_CarnivorePlant[0]->type=Ent_CarnivorePlant;
|
||||
ent_CarnivorePlant[0]->flags=0;
|
||||
ent_CarnivorePlant[0]->zorder=1;
|
||||
AnimPlay_SetImg(&ent_CarnivorePlant[0]->anim,img_carnivorePlant[0]);
|
||||
ent_CarnivorePlant[0]->mass=0.0f;
|
||||
ent_CarnivorePlant[0]->radius=16;
|
||||
ent_CarnivorePlant[0]->child=ent_Spike[0];
|
||||
ent_CarnivorePlant[1]=Entity_Copy(ent_CarnivorePlant[0]);
|
||||
AnimPlay_SetImg(&ent_CarnivorePlant[1]->anim,img_carnivorePlant[1]);
|
||||
|
||||
|
||||
// Bunny
|
||||
ent_Bunny=Entity_New();
|
||||
ent_Bunny->type=Ent_Bunny;
|
||||
ent_Bunny->flags=EntityFlag_Collision;
|
||||
ent_Bunny->zorder=0;
|
||||
AnimPlay_SetImg(&ent_Bunny->anim,img_bunny[0]);
|
||||
ent_Bunny->proc=bunny_proc;
|
||||
ent_Bunny->collision=bunny_collision;
|
||||
ent_Bunny->mass=1.0f;
|
||||
ent_Bunny->radius=12;
|
||||
ent_Bunny->width=24;
|
||||
ent_Bunny->height=24;
|
||||
ent_Bunny->fric_static=0.0f;
|
||||
ent_Bunny->fric_dynamic=0.2f;
|
||||
ent_Bunny->A=0;
|
||||
ent_Bunny->B=0;
|
||||
ent_Bunny->C=60;
|
||||
|
||||
|
||||
// Spider
|
||||
ent_Spider=Entity_New();
|
||||
ent_Spider->type=Ent_Spider;
|
||||
ent_Spider->flags=EntityFlag_Collision;
|
||||
ent_Spider->zorder=0;
|
||||
AnimPlay_SetImg(&ent_Spider->anim,img_spider[0]);
|
||||
ent_Spider->proc=spider_proc;
|
||||
ent_Spider->collision=spider_collision;
|
||||
ent_Spider->mass=1.0f;
|
||||
ent_Spider->radius=12;
|
||||
ent_Spider->width=24;
|
||||
ent_Spider->height=24;
|
||||
ent_Spider->fric_static=0.0f;
|
||||
ent_Spider->fric_dynamic=0.2f;
|
||||
ent_Spider->A=0;
|
||||
ent_Spider->B=0;
|
||||
ent_Spider->C=60;
|
||||
|
||||
// FIXME: Guard
|
||||
|
||||
// FIXME: Elite Guard
|
||||
|
||||
// FIXEM: Axe
|
||||
|
||||
// FIXME: GoatMan
|
||||
|
||||
// FIXME: Princess
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -10,62 +10,16 @@ enum {
|
||||
Ent_Platform,
|
||||
Ent_Block,
|
||||
|
||||
Ent_Wizard,
|
||||
Ent_MagikBall,
|
||||
Ent_Earth,
|
||||
Ent_EarthBack,
|
||||
Ent_StoneBrick,
|
||||
Ent_StoneBrickBack,
|
||||
Ent_SpikedBush,
|
||||
Ent_LavaPit,
|
||||
Ent_Fireball,
|
||||
Ent_Flower,
|
||||
Ent_Spike,
|
||||
Ent_CarnivorePlant,
|
||||
Ent_Bunny,
|
||||
Ent_Spider,
|
||||
Ent_Guard,
|
||||
Ent_EliteGuard,
|
||||
Ent_Axe,
|
||||
Ent_GoatMan,
|
||||
Ent_Princess
|
||||
Ent_Last
|
||||
} EntityType;
|
||||
|
||||
extern Entity ent_Player;
|
||||
extern Entity ent_Platform;
|
||||
extern Entity ent_Block;
|
||||
|
||||
extern Entity ent_Wizard;
|
||||
extern Entity ent_MagikBall;
|
||||
extern Entity ent_Earth;
|
||||
extern Entity ent_EarthBack;
|
||||
extern Entity ent_StoneBrick;
|
||||
extern Entity ent_StoneBrickBack;
|
||||
extern Entity ent_SpikedBush;
|
||||
extern Entity ent_LavaPit;
|
||||
extern Entity ent_Fireball;
|
||||
extern Entity ent_Spike[2];
|
||||
extern Entity ent_Flower[2];
|
||||
extern Entity ent_CarnivorePlant[2];
|
||||
extern Entity ent_Bunny;
|
||||
extern Entity ent_Spider;
|
||||
extern Entity ent_Axe;
|
||||
extern Entity ent_Guard;
|
||||
extern Entity ent_EliteGuard;
|
||||
extern Entity ent_GoatMan;
|
||||
extern Entity ent_Princess;
|
||||
|
||||
|
||||
int EntityApplyGravity(Entity e);
|
||||
|
||||
void EntEarth_Init(Entity ent,int up,int down,int left,int right);
|
||||
|
||||
void EntStoneBrick_Init(Entity ent,int up,int down,int left,int right);
|
||||
|
||||
|
||||
void GameEnts_Init();
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -105,64 +105,17 @@ int GameMap_LoadLevel(char *filename,int res){
|
||||
|
||||
if(MAP(i,j)=='P'){
|
||||
// Player
|
||||
GameMapAux_CreateEnt(ent_Wizard,i,j,res);
|
||||
GameMapAux_CreateEnt(ent_Player,i,j,res);
|
||||
}
|
||||
if(MAP(i,j)=='#'){
|
||||
// Earth
|
||||
int x,y;
|
||||
int up,down,left,right;
|
||||
|
||||
ent=GameMapAux_CreateEnt(ent_Earth,i,j,res);
|
||||
|
||||
x=i;y=j-1;if(y<0)y=0;
|
||||
up=MAP(x,y)=='#'?0:1;
|
||||
x=i;y=j+1;if(y>=height)y=height-1;
|
||||
down=MAP(x,y)=='#'?0:1;
|
||||
x=i-1;y=j;if(x<0)x=0;
|
||||
left=MAP(x,y)=='#'?0:1;
|
||||
x=i+1;y=j;if(x>=width)x=width-1;
|
||||
right=MAP(x,y)=='#'?0:1;
|
||||
|
||||
EntEarth_Init(ent,up,down,left,right);
|
||||
// Block
|
||||
ent=GameMapAux_CreateEnt(ent_Block,i,j,res);
|
||||
}
|
||||
if(MAP(i,j)=='R'){
|
||||
// StoneBrick
|
||||
int x,y;
|
||||
int up,down,left,right;
|
||||
|
||||
ent=GameMapAux_CreateEnt(ent_StoneBrick,i,j,res);
|
||||
|
||||
x=i;y=j-1;if(y<0)y=0;
|
||||
up=MAP(x,y)=='R'?0:1;
|
||||
x=i;y=j+1;if(y>=height)y=height-1;
|
||||
down=MAP(x,y)=='R'?0:1;
|
||||
x=i-1;y=j;if(x<0)x=0;
|
||||
left=MAP(x,y)=='R'?0:1;
|
||||
x=i+1;y=j;if(x>=width)x=width-1;
|
||||
right=MAP(x,y)=='R'?0:1;
|
||||
|
||||
EntStoneBrick_Init(ent,up,down,left,right);
|
||||
if(MAP(i,j)=='|'){
|
||||
// Platform
|
||||
ent=GameMapAux_CreateEnt(ent_Platform,i,j,res);
|
||||
}
|
||||
|
||||
|
||||
if(MAP(i,j)=='S'){
|
||||
// Spiked Bush
|
||||
ent=GameMapAux_CreateEnt(ent_SpikedBush,i,j,res);
|
||||
}
|
||||
|
||||
if(MAP(i,j)=='F'){
|
||||
// Flower
|
||||
ent=GameMapAux_CreateEnt(ent_Flower[0],i,j,res);
|
||||
}
|
||||
if(MAP(i,j)=='f'){
|
||||
// Flower
|
||||
ent=GameMapAux_CreateEnt(ent_Flower[1],i,j,res);
|
||||
}
|
||||
|
||||
if(MAP(i,j)=='B'){
|
||||
// Bunny
|
||||
ent=GameMapAux_CreateEnt(ent_Bunny,i,j,res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
27
Game/main.c
27
Game/main.c
@@ -16,8 +16,6 @@ extern int gamelib_debug;
|
||||
DrawFnt font;
|
||||
DrawFnt font_shad;
|
||||
|
||||
DrawImg img_background;
|
||||
|
||||
void ProcGame(){
|
||||
|
||||
}
|
||||
@@ -27,24 +25,6 @@ void PostProcGame(){
|
||||
GameLib_ForEachEnt(EntityApplyGravity);
|
||||
}
|
||||
|
||||
void PreDrawGame(float f){
|
||||
//Draw_Clean(128,128,128);
|
||||
Draw_SetColor(1.0f,1.0f,1.0f,1.0f);
|
||||
Draw_DrawImgResized(img_background,0,0,640,480);
|
||||
}
|
||||
|
||||
void DrawGame(float f){
|
||||
char cadena[128];
|
||||
|
||||
// Watermark
|
||||
Draw_SetColor(0,0,0,0.3);
|
||||
Draw_DrawText(font,"By Kableado (VAR)",201,461);
|
||||
Draw_SetColor(1.0f,1.0f,1.0f,0.3f);
|
||||
Draw_DrawText(font,"By Kableado (VAR)",200,460);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc,char *argv[]){
|
||||
int i,j;
|
||||
@@ -70,9 +50,6 @@ int main(int argc,char *argv[]){
|
||||
font=Draw_DefaultFont(255,255,255,255);
|
||||
font_shad=Draw_DefaultFont(0,0,0,127);
|
||||
|
||||
img_background=Draw_LoadImage("data/heaven.png");
|
||||
Draw_SetOffset(img_background,0,0);
|
||||
|
||||
GameEnts_Init();
|
||||
|
||||
|
||||
@@ -80,14 +57,14 @@ int main(int argc,char *argv[]){
|
||||
// Initialize world.
|
||||
//
|
||||
GameLib_DelEnts();
|
||||
GameMap_LoadLevel("data/level_01.txt",32);
|
||||
GameMap_LoadLevel("data/level_01.txt",64);
|
||||
|
||||
|
||||
/////////////////////////
|
||||
// Run the world.
|
||||
//
|
||||
|
||||
GameLib_Loop(ProcGame,PostProcGame,PreDrawGame,DrawGame);
|
||||
GameLib_Loop(ProcGame,PostProcGame,NULL,NULL);
|
||||
|
||||
|
||||
return(0);
|
||||
|
||||
Reference in New Issue
Block a user