Skip to content

Commit

Permalink
Add catapult
Browse files Browse the repository at this point in the history
Remove unused icons
Unit in city attacking doesn't move out of city
  • Loading branch information
jzeiber committed Nov 16, 2023
1 parent 72ff7c4 commit 3969a6f
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 244 deletions.
2 changes: 1 addition & 1 deletion bundle/index.html

Large diffs are not rendered by default.

Binary file modified cart/cart.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion src/src/defines.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#define VERSION_STR "v0.2"
#define VERSION_STR "v0.3"
#define MAX_CIVILIZATIONS 4
#define CITIES_PER_CIVILIZATION 8
#define MAX_CITIES MAX_CIVILIZATIONS*CITIES_PER_CIVILIZATION
Expand Down
10 changes: 10 additions & 0 deletions src/src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,16 @@ bool Game::MoveUnit(const uint8_t civindex, const int32_t unitindex, const int32
AddSpriteOverlay(eu->x,eu->y,SpriteSheetPos(2,0),60);
DisbandUnit(-1,eu-m_gamedata.m_unit,true);

// attacking unit was in a city - don't move them out of city and subtract movement point
if(CityIndexAtLocation(u->x,u->y)>=0)
{
trymove=false;
if(u->movesleft>0)
{
u->movesleft--;
}
}

// if the enemy was in a city - then we killed the unit, take a movement point away and don't try to enter city
// if there was more than 1 enemy at dest, take a movement point away and don't try to move
if(ec || eucount>1)
Expand Down
4 changes: 2 additions & 2 deletions src/src/gamedata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void GameData::SaveGame()
memset(buff,0,1024);

uint32_t pos=0;
uint32_t magic=0x01020002;
uint32_t magic=0x01020003;
memcpy(&buff[pos],&magic,4);
pos+=4;

Expand Down Expand Up @@ -220,7 +220,7 @@ bool GameData::LoadGame()
memcpy(&magic,&buff[pos],4);
pos+=4;

if(magic==0x01020002)
if(magic==0x01020003)
{
memcpy(&m_seed,&buff[pos],sizeof(m_seed));
pos+=sizeof(m_seed);
Expand Down
26 changes: 13 additions & 13 deletions src/src/icondata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
const IconData icondata[]={
// icontype, name, xidx, yidx
{/*ICON_NONE,*/ nullptr, 0, 0},
{/*ICON_NEXTUNIT,*/ "Next Unit", 6, 3},
{/*ICON_NEXTLOCUNIT,*/ "Next Unit At Loc", 7, 3},
{/*ICON_NEXTCITY,*/ "Next City", 4, 3},
{/*ICON_SCROLLMAP,*/ "Scroll Map", 4, 2},
{/*ICON_TOGGLEINFO,*/ "Toggle Info", 5, 2},
{/*ICON_NEXTUNIT,*/ "Next Unit", 7, 0},
{/*ICON_NEXTLOCUNIT,*/ "Next Unit At Loc", 8, 0},
{/*ICON_NEXTCITY,*/ "Next City", 4, 0},
{/*ICON_SCROLLMAP,*/ "Scroll Map", 2, 1},
{/*ICON_TOGGLEINFO,*/ "Toggle Info", 9, 1},
{/*ICON_ENDTURN,*/ "End Turn", 5, 1},
{/*ICON_VIEWMAP,*/ "View Map", 1, 2},
{/*ICON_FOUNDCITY,*/ "Found City", 6, 2},
{/*ICON_CLOSE,*/ "Close", 7, 2},
{/*ICON_CIVDATA,*/ "Civ Data", 0, 2},
{/*ICON_ENTERCITY,*/ "Enter City", 11, 3},
{/*ICON_DISBAND,*/ "Disband", 10, 3},
{/*ICON_EXPANDCITY,*/ "Expand City", 6, 2},
{/*ICON_CHANGEBUILD,*/ "Change Build", 6, 2},
{/*ICON_VIEWMAP,*/ "View Map", 1, 1},
{/*ICON_FOUNDCITY,*/ "Found City", 6, 1},
{/*ICON_CLOSE,*/ "Close", 7, 1},
{/*ICON_CIVDATA,*/ "Civ Data", 0, 1},
{/*ICON_ENTERCITY,*/ "Enter City", 11, 1},
{/*ICON_DISBAND,*/ "Disband", 10, 1},
{/*ICON_EXPANDCITY,*/ "Expand City", 6, 1},
{/*ICON_CHANGEBUILD,*/ "Change Build", 6, 1},
{/*ICON_BUYBUILD,*/ "Buy", 5, 0},
{/*ICON_SELLIMPROVEMENTS,*/ "Sell Improvement", 6, 0}
};
1 change: 1 addition & 0 deletions src/src/improvementdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const BuildingXref buildingxref[]={
{/*BUILDING_PHALANX,*/ BUILDINGTYPE_UNIT, UNITTYPE_PHALANX},
{/*BUILDING_TRIREME,*/ BUILDINGTYPE_UNIT, UNITTYPE_TRIREME},
{/*BUILDING_HORSEMAN,*/ BUILDINGTYPE_UNIT, UNITTYPE_HORSEMAN},
{/*BUILDING_CATAPULT,*/ BUILDINGTYPE_UNIT, UNITTYPE_CATAPULT},
{/*BUILDING_KNIGHT,*/ BUILDINGTYPE_UNIT, UNITTYPE_KNIGHT},
{/*BUILDING_SAIL,*/ BUILDINGTYPE_UNIT, UNITTYPE_SAIL},
{/*BUILDING_GRANARY,*/ BUILDINGTYPE_IMPROVEMENT, IMPROVEMENT_GRANARY},
Expand Down
1 change: 1 addition & 0 deletions src/src/improvementdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ BUILDING_ARCHER,
BUILDING_PHALANX,
BUILDING_TRIREME,
BUILDING_HORSEMAN,
BUILDING_CATAPULT,
BUILDING_KNIGHT,
BUILDING_SAIL,
BUILDING_UNIT_MAX=BUILDING_SAIL,
Expand Down
350 changes: 127 additions & 223 deletions src/src/sprites.cpp

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/src/stategame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1454,11 +1454,11 @@ void StateGame::DrawHourGlass(const uint8_t playerindex)
*DRAW_COLORS=(PALETTE_WHITE << 4) | PALETTE_BLACK;
if(((m_game->GetGameData().m_ticks/60)%2)==0)
{
blitMasked(icongfx,icongfxalpha,SCREEN_SIZE-16,SCREEN_SIZE-16,16,16,8*16,2*16,icongfxwidth,BLIT_1BPP);
blitMasked(icongfx,icongfxalpha,SCREEN_SIZE-16,SCREEN_SIZE-16,16,16,8*16,1*16,icongfxwidth,BLIT_1BPP);
}
else
{
blitMasked(icongfx,icongfxalpha,SCREEN_SIZE-16,SCREEN_SIZE-16,16,16,8*16,2*16,icongfxwidth,BLIT_1BPP|BLIT_ROTATE);
blitMasked(icongfx,icongfxalpha,SCREEN_SIZE-16,SCREEN_SIZE-16,16,16,8*16,1*16,icongfxwidth,BLIT_1BPP|BLIT_ROTATE);
}

OutputStringStream ostr;
Expand Down
1 change: 1 addition & 0 deletions src/src/unitdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const UnitData unitdata[]={
{/*UNITTYPE_PHALANX,*/ "Phalanx", UNITDATA_MOVE_LAND, 11, 7, 1, 0, 1, 2, 1, 1, 1, 200, 250},
{/*UNITTYPE_TRIREME,*/ "Trireme", UNITDATA_MOVE_WATER, 11, 6, 2, 1, 2, 1, 1, 1, 1, 250, 350},
{/*UNITTYPE_HORSEMAN,*/ "Horseman", UNITDATA_MOVE_LAND, 8, 7, 3, 0, 2, 2, 1, 1, 1, 350, 400},
{/*UNITTYPE_CATAPULT,*/ "Catapult", UNITDATA_MOVE_LAND, 8, 8, 1, 0, 6, 1, 1, 1, 1, 400, 500},
{/*UNITTYPE_KNIGHT,*/ "Knight", UNITDATA_MOVE_LAND, 9, 7, 4, 0, 4, 2, 1, 1, 2, 500, 600},
{/*UNITTYPE_SAIL,*/ "Sail", UNITDATA_MOVE_WATER, 10, 7, 4, 2, 3, 2, 2, 2, 3, 600, 700}
};
5 changes: 3 additions & 2 deletions src/src/unitdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ enum UnitType
UNITTYPE_PHALANX= 4,
UNITTYPE_TRIREME= 5,
UNITTYPE_HORSEMAN= 6,
UNITTYPE_KNIGHT= 7,
UNITTYPE_SAIL= 8,
UNITTYPE_CATAPULT= 7,
UNITTYPE_KNIGHT= 8,
UNITTYPE_SAIL= 9,
UNITTYPE_MAX
};

Expand Down

0 comments on commit 3969a6f

Please sign in to comment.