mirror of
https://github.com/stevenhowes/CTheEscape.git
synced 2026-05-27 00:03:27 +01:00
Collidable sprites in mapedit, correct triggering of smarttiles in mission2
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+35
-14
@@ -247,11 +247,23 @@ void game2_tick_input()
|
||||
readmodkey = tick + 10;
|
||||
}
|
||||
}
|
||||
// C
|
||||
|
||||
// S
|
||||
if(input_readkey(81))
|
||||
{
|
||||
game2_savemap("mission2");
|
||||
}
|
||||
|
||||
// H
|
||||
if(input_readkey(84))
|
||||
{
|
||||
if(tick > readmodkey)
|
||||
{
|
||||
fullmap[TilePlayer.rawtile] = fullmap[TilePlayer.rawtile] ^ 128;
|
||||
readmodkey = tick + 10;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int game2_tick()
|
||||
@@ -276,8 +288,12 @@ int game2_tick()
|
||||
if(1/*map[0][x][y] ^ map[screen+1][x][y]*/)
|
||||
{
|
||||
map[screen+1][x][y] = map[0][x][y];
|
||||
sprintf(tilenamebuffer,"%i",map[screen+1][x][y]);
|
||||
sprintf(tilenamebuffer,"%i",map[screen+1][x][y] & 127);
|
||||
draw_tile(tilenamebuffer,x*100,y*100);
|
||||
if(((map[screen+1][x][y] >> 7) & 0x01))
|
||||
{
|
||||
draw_sprite("solid",x*100,y*100);
|
||||
}
|
||||
udt++;
|
||||
}
|
||||
|
||||
@@ -294,7 +310,6 @@ int game2_tick()
|
||||
TilePlayer.localtile.Y = y;
|
||||
if(screen)
|
||||
draw_sprite("select1",x*100,y*100);
|
||||
|
||||
else
|
||||
draw_sprite("select2",x*100,y*100);
|
||||
}
|
||||
@@ -306,7 +321,12 @@ int game2_tick()
|
||||
draw_sprite("lcarsblack",1000,DISPLAY_Y-164);
|
||||
|
||||
TilePlayer.rawtile = (TilePlayer.mapoffset.Y) + TilePlayer.localtile.Y + (TilePlayer.mapoffset.X * 100) + (TilePlayer.localtile.X * 100);
|
||||
sprintf(textbuffer,"Tile:%i\nSprite:%i",TilePlayer.rawtile,fullmap[TilePlayer.rawtile]);
|
||||
|
||||
sprintf(textbuffer,"Tile:%i\nSprite:%i\nSolid: %i",
|
||||
TilePlayer.rawtile,
|
||||
fullmap[TilePlayer.rawtile],
|
||||
((fullmap[TilePlayer.rawtile] >> 7) & 0x01)
|
||||
);
|
||||
draw_spritetext(textbuffer, 1070, 950);
|
||||
|
||||
game2_tick_input();
|
||||
@@ -315,18 +335,19 @@ int game2_tick()
|
||||
|
||||
x = 1100;
|
||||
y = 600;
|
||||
|
||||
for(i = (fullmap[TilePlayer.rawtile] - 3); i <= (fullmap[TilePlayer.rawtile] + 3); i++)
|
||||
{
|
||||
if((i >=0) && (i <= 255))
|
||||
{
|
||||
sprintf(tilenamebuffer,"%i",i);
|
||||
draw_tile(tilenamebuffer,x,y);
|
||||
sprintf(tilenamebuffer,"%i",i);
|
||||
draw_tile(tilenamebuffer,x,y);
|
||||
|
||||
sprintf(textbuffer,"%d",i);
|
||||
draw_spritetext(textbuffer, x-60, y+30);
|
||||
sprintf(textbuffer,"%d",i);
|
||||
draw_spritetext(textbuffer, x-60, y+30);
|
||||
|
||||
if(i == fullmap[TilePlayer.rawtile])
|
||||
draw_sprite("select1",x,y);
|
||||
if(i == fullmap[TilePlayer.rawtile])
|
||||
draw_sprite("select1",x,y);
|
||||
}
|
||||
y = y - 100;
|
||||
}
|
||||
@@ -334,11 +355,11 @@ int game2_tick()
|
||||
x = 1180;
|
||||
y = 750;
|
||||
|
||||
sprintf(tilenamebuffer,"%i",clipboard);
|
||||
draw_tile(tilenamebuffer,x,y);
|
||||
draw_sprite("select1",x,y);
|
||||
sprintf(tilenamebuffer,"%i",clipboard);
|
||||
draw_tile(tilenamebuffer,x,y);
|
||||
draw_sprite("select1",x,y);
|
||||
|
||||
draw_spritetext("Clipboard", x-174, y+30);
|
||||
draw_spritetext("Clipboard", x-174, y+30);
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
+51
-22
@@ -94,15 +94,33 @@ void game2_loadmap(char* filename)
|
||||
SmartTiles[0].Tile = 1206;
|
||||
SmartTiles[0].ActionTarget = 1206;
|
||||
SmartTiles[0].Action = 0;
|
||||
SmartTiles[0].ActionValue = 1;
|
||||
SmartTiles[0].ActionValue = 16;
|
||||
|
||||
SmartTiles[1].Tile = 1207;
|
||||
SmartTiles[1].ActionTarget = 1206;
|
||||
SmartTiles[1].Action = 0;
|
||||
SmartTiles[1].ActionValue = 16;
|
||||
SmartTiles[2].Tile = 1205;
|
||||
|
||||
SmartTiles[2].Tile = 1107;
|
||||
SmartTiles[2].ActionTarget = 1206;
|
||||
SmartTiles[2].Action = 0;
|
||||
SmartTiles[2].ActionValue = 16;
|
||||
SmartTiles[2].ActionValue = 17;
|
||||
|
||||
SmartTiles[3].Tile = 1208;
|
||||
SmartTiles[3].ActionTarget = 1206;
|
||||
SmartTiles[3].Action = 0;
|
||||
SmartTiles[3].ActionValue = 17;
|
||||
|
||||
SmartTiles[4].Tile = 1307;
|
||||
SmartTiles[4].ActionTarget = 1206;
|
||||
SmartTiles[4].Action = 0;
|
||||
SmartTiles[4].ActionValue = 17;
|
||||
|
||||
|
||||
SmartTiles[5].Tile = 1205;
|
||||
SmartTiles[5].ActionTarget = 1206;
|
||||
SmartTiles[5].Action = 0;
|
||||
SmartTiles[5].ActionValue = 17;
|
||||
game2_savesmarttiles("m2_smart");
|
||||
}
|
||||
|
||||
@@ -251,7 +269,7 @@ int game2_tick()
|
||||
int x;
|
||||
int y;
|
||||
int i;
|
||||
int udt = 0;
|
||||
|
||||
lasttick = tick;
|
||||
tick = clock();
|
||||
|
||||
@@ -259,22 +277,14 @@ int game2_tick()
|
||||
|
||||
if(1)
|
||||
{
|
||||
for(i = 0; i < SMARTTILES; i++)
|
||||
{
|
||||
if(SmartTiles[i].Tile == TilePlayer.rawtile)
|
||||
{
|
||||
// Change tile sprite
|
||||
if(SmartTiles[i].Action == 0)
|
||||
fullmap[SmartTiles[i].ActionTarget] = SmartTiles[i].ActionValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Fill the map0 with our chunk of the full map
|
||||
game2_fillmap(TilePlayer.mapoffset.X,TilePlayer.mapoffset.Y);
|
||||
|
||||
for(x = 0; x < TILESX; x++)
|
||||
{
|
||||
for(y = 0; y < TILESY; y++)
|
||||
{
|
||||
// Finds any tile we collide with
|
||||
if(game_hitbox_collide(
|
||||
(TilePlayer.location.X + TilePlayer.hitbox_bl.X),(TilePlayer.location.Y + TilePlayer.hitbox_bl.Y),
|
||||
(TilePlayer.hitbox_tr.X - TilePlayer.hitbox_bl.X),(TilePlayer.hitbox_tr.Y - TilePlayer.hitbox_bl.Y),
|
||||
@@ -284,27 +294,46 @@ int game2_tick()
|
||||
{
|
||||
map[1][x][y] = 255;
|
||||
map[2][x][y] = 255;
|
||||
}
|
||||
|
||||
// Find the tile under our centre of mass
|
||||
if(game_hitbox_collide(
|
||||
(TilePlayer.location.X + TilePlayer.hitbox_bl.X + (TilePlayer.hitbox_tr.X/2)),(TilePlayer.location.Y + TilePlayer.hitbox_bl.Y + (TilePlayer.hitbox_tr.Y/2)),
|
||||
(1),(1),
|
||||
x*100,y*100,
|
||||
100,100
|
||||
))
|
||||
{
|
||||
TilePlayer.localtile.X = x;
|
||||
TilePlayer.localtile.Y = y;
|
||||
}
|
||||
|
||||
// Redraw any tiles we're overlapping
|
||||
if(map[0][x][y] ^ map[screen+1][x][y])
|
||||
{
|
||||
map[screen+1][x][y] = map[0][x][y];
|
||||
sprintf(tilenamebuffer,"%i",map[screen+1][x][y]);
|
||||
if(map[screen+1][x][y] < 128)
|
||||
sprintf(tilenamebuffer,"%i",map[screen+1][x][y]);
|
||||
else
|
||||
sprintf(tilenamebuffer,"%i",(map[screen+1][x][y]-128));
|
||||
|
||||
draw_tile(tilenamebuffer,x*100,y*100);
|
||||
udt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TilePlayer.rawtile = (TilePlayer.mapoffset.Y) + TilePlayer.localtile.Y + (TilePlayer.mapoffset.X * 100) + (TilePlayer.localtile.X * 100);
|
||||
|
||||
/* draw_sprite("lcarsblack",1000,DISPLAY_Y-164);
|
||||
|
||||
|
||||
sprintf(textbuffer,"Tile:%i\nSprite:%i",TilePlayer.rawtile,fullmap[TilePlayer.rawtile]);
|
||||
draw_spritetext(textbuffer, 1070, 950);*/
|
||||
// Trigger any smart tiles for our centre of mass
|
||||
for(i = 0; i < SMARTTILES; i++)
|
||||
{
|
||||
if(SmartTiles[i].Tile == TilePlayer.rawtile)
|
||||
{
|
||||
// Change tile sprite
|
||||
if(SmartTiles[i].Action == 0)
|
||||
fullmap[SmartTiles[i].ActionTarget] = SmartTiles[i].ActionValue;
|
||||
}
|
||||
}
|
||||
|
||||
game2_tick_input();
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user