Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.o
sea
sea.exe
sea.cfg
.deps/
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ DEPDIR = .deps
df = $(DEPDIR)/$(*F)

%.o : %.cpp
@$(MAKEDEPEND); \
@test -d $(DEPDIR) || mkdir $(DEPDIR); \
$(MAKEDEPEND); \
cp $(df).d $(df).P; \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $(df).d >> $(df).P; \
Expand Down
25 changes: 23 additions & 2 deletions boat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@
#include "snoutlib/timer.h"
#include "game.h"
#include "fx_ship_expl.h"
#include "data/text/shipnames.h"

int Boat::m_names_used[];

Boat::Boat(vec2 pos,string name,float scale) :
m_pos(pos),m_name(name),m_scale(scale),
Boat::Boat(vec2 pos,int index,float scale) :
m_pos(pos),m_scale(scale),
m_pos_shift(0.0),m_rot(0.0),
m_damaged(false),m_sinking(false), m_obb(AABB(0,0,0,0))
{
m_model = &g_resources.mesh_tanker;
m_name = randname(index);

m_smoke = NULL;
for(int i=0;i<m_num_bubble_streams;++i)
Expand All @@ -31,6 +34,24 @@ Boat::~Boat()
delete m_bbl[i];
}

string Boat::randname(int idx) {
if(idx == 0) {
int max_idx = 0;
while(ship_names[max_idx])
max_idx++;

m_names_used[0] = m_names_used[1] = m_names_used[2] = rand() % max_idx;
do {
m_names_used[1] = rand() % max_idx;
} while(m_names_used[0] == m_names_used[1]);
do {
m_names_used[2] = rand() % max_idx;
} while(m_names_used[2] == m_names_used[0] || m_names_used[2] == m_names_used[1]);

}
return string(ship_names[m_names_used[idx]]);
}

void Boat::hit(float x)
{
float hit_pos = x - m_pos[0];
Expand Down
5 changes: 4 additions & 1 deletion boat.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class Boat
{
static const int m_num_bubble_streams = 5;
static int m_names_used[3];

StaticMesh **m_model;
vec2 m_pos;
Expand All @@ -32,10 +33,12 @@ class Boat
ParticleEffect *m_bbl[m_num_bubble_streams];
float m_bbl_emitpos_x[m_num_bubble_streams];

string randname(int index);

public:
OBB m_obb;

Boat(vec2 pos,string name="",float scale=0.41);
Boat(vec2 pos,int index,float scale=0.41);
~Boat();

void draw(void);
Expand Down
18 changes: 18 additions & 0 deletions data/text/shipnames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const char *ship_names[] = {
"Rainbow Warrior",
"Titanic",
"Exxon Valdez",
"Deepwater Horizon",
"Urquiola",
"Torrey Canyon",
"Irenes Serenade",
"Sea Star",
"MT Haven",
"Amoco Cadiz",
"Castillo de Bellver",
"ABT Summer",
"Atlantic Empress",
"Ixtoc I",
"Bismarck",
NULL
};
9 changes: 3 additions & 6 deletions game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ extern App *g_app;

Game::Game(int difficulty,int wave) : m_score(0), m_difficulty(difficulty), m_wave(wave), m_hiscore_name(""), m_ended(false)
{
m_boats[0] = new Boat(vec2(0.37f,0.24f),"S.S. Epic Failure");
m_boats[1] = new Boat(vec2(0.80f,0.24f),"The Slightly Radioactive Whale");
m_boats[2] = new Boat(vec2(1.23f,0.24f),"Nice Boat");
m_boats[0] = new Boat(vec2(0.37f,0.24f),0);
m_boats[1] = new Boat(vec2(0.80f,0.24f),1);
m_boats[2] = new Boat(vec2(1.23f,0.24f),2);

m_pboat1 = new PBoat(vec2(0.08f,0.25f));
m_pboat2 = new PBoat(vec2(1.52f,0.25f));
Expand Down Expand Up @@ -253,9 +253,6 @@ void Game::gamemode_specific_stuff(void)
switch(m_gamemode) {
//
case GM_STARTWAVE:
m_pboat1->reload_ammo();
m_pboat2->reload_ammo();

if (gm_time<=3.0) {
float alpha = fade_in_out(0.0, 0.5, 2.5, 3.0, gm_time);
alpha = clamp<float>(alpha,0.0,1.0);
Expand Down