Skip to content

Commit

Permalink
Sort out some monster slowness issues
Browse files Browse the repository at this point in the history
  • Loading branch information
orudge committed May 15, 2008
1 parent d741f76 commit a503a20
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 44 deletions.
2 changes: 2 additions & 0 deletions blocks3.h
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ extern volatile int close_button_pressed;
void Start_XYZ(int b_x, int b_y, int b_z, int b_dx, int b_dy, int b_dir);
void Track_Laser(void);
void Laser(void);
void Draw_Lasers();

// levels.c
void Change_Levels(void);
Expand Down Expand Up @@ -588,6 +589,7 @@ enum {
};

// mon.c
void Draw_Monsters();
void Monster(void);
void Monster_Draw(int m_no);
void Monster_Mon0(int m_no);
Expand Down
94 changes: 53 additions & 41 deletions laser.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,60 @@ int x, y, z, dx, dy;

void Laser(void)
{
int i, j, k;
int map_laser_back[20][15][2];

for (i = 0; i < 20; i++)
for (j = 0; j < 15; j++)
{
map_laser_back[i][j][0] = map_laser[i][j][0];
map_laser_back[i][j][1] = map_laser[i][j][1];

map_laser[i][j][0] = 0;
map_laser[i][j][1] = 0;
}

for (i = 0; i < box_count; i++)
{
if (box[i].type & LASER)
{
if (box[i].type == LASER_4WAY)
{
Start_XYZ(box[i].x, box[i].y, box[i].z, box[i].dx, box[i].dy, 1);
Track_Laser();
Start_XYZ(box[i].x, box[i].y, box[i].z, box[i].dx, box[i].dy, 2);
Track_Laser();
Start_XYZ(box[i].x, box[i].y, box[i].z, box[i].dx, box[i].dy, 4);
Track_Laser();
Start_XYZ(box[i].x, box[i].y, box[i].z, box[i].dx, box[i].dy, 8);
Track_Laser();
}
else
{
Start_XYZ(box[i].x, box[i].y, box[i].z, box[i].dx, box[i].dy, box[i].dir);
Track_Laser();
}
}
}


for (i = 0; i < 20; i++)
for (j = 0; j < 15; j++)
for (k = 0; k < 2; k++)
if (map_laser[i][j][k] != map_laser_back[i][j][k]) DirtyList(i*_block_width, j*_block_height, k*_block_depth, _block_width, _block_height_depth, blank);
int i, j, k;
int map_laser_back[20][15][2];

for (i = 0; i < 20; i++)
{
for (j = 0; j < 15; j++)
{
map_laser_back[i][j][0] = map_laser[i][j][0];
map_laser_back[i][j][1] = map_laser[i][j][1];

map_laser[i][j][0] = 0;
map_laser[i][j][1] = 0;
}
}

for (i = 0; i < box_count; i++)
{
if (box[i].type & LASER)
{
if (box[i].type == LASER_4WAY)
{
Start_XYZ(box[i].x, box[i].y, box[i].z, box[i].dx, box[i].dy, 1);
Track_Laser();
Start_XYZ(box[i].x, box[i].y, box[i].z, box[i].dx, box[i].dy, 2);
Track_Laser();
Start_XYZ(box[i].x, box[i].y, box[i].z, box[i].dx, box[i].dy, 4);
Track_Laser();
Start_XYZ(box[i].x, box[i].y, box[i].z, box[i].dx, box[i].dy, 8);
Track_Laser();
}
else
{
Start_XYZ(box[i].x, box[i].y, box[i].z, box[i].dx, box[i].dy, box[i].dir);
Track_Laser();
}
}
}

for (i = 0; i < 20; i++)
{
for (j = 0; j < 15; j++)
{
for (k = 0; k < 2; k++)
{
if (map_laser[i][j][k] != map_laser_back[i][j][k])
DirtyList(i*_block_width, j*_block_height, k*_block_depth, _block_width, _block_height_depth, blank);
}
}
}
}

void Draw_Lasers()
{
// TODO: sort out properly
}

void Start_XYZ(int b_x, int b_y, int b_z, int b_dx, int b_dy, int b_dir)
Expand Down
15 changes: 13 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ int Run_Level(void)
if (no_ply == 2)
Player_Pickup_Check(1);

Player_Draw(0);
/* Player_Draw(0);
if (no_ply == 2)
Player_Draw(1);
Player_Draw(1);*/

Check_Fall(0);

Expand Down Expand Up @@ -211,6 +211,17 @@ int Run_Level(void)
#endif
}

Player_Draw(0);

if (no_ply == 2)
Player_Draw(1);

Draw_Monsters();
//Draw_Lasers();
// still todo: Doors

//

Draw_Explode();

Draw_Screen();
Expand Down
10 changes: 9 additions & 1 deletion mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void Monster(void)
if (mon[i].type == MON2) Monster_Mon1(i);
}

Monster_Draw(i);
// Monster_Draw(i);
}

for (k = 0; k < 2; k++)
Expand All @@ -42,6 +42,14 @@ void Monster(void)
}
}

void Draw_Monsters()
{
int i;

for (i = 0; i < mon_count; i++)
Monster_Draw(i);
}

void Monster_Draw(int m_no)
{
if ((mon[m_no].dx) || (mon[m_no].dy)) mon[m_no].frame++;
Expand Down

0 comments on commit a503a20

Please sign in to comment.