Skip to content

Commit

Permalink
Tweaks, random event added
Browse files Browse the repository at this point in the history
  • Loading branch information
AbuDhabi committed Oct 20, 2012
1 parent 8dd9d73 commit 0c660b5
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 18 deletions.
32 changes: 16 additions & 16 deletions Viking Trail.layout
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<File name="buy_stuff.cpp" open="0" top="0" tabpos="9">
<Cursor position="2991" topLine="68" />
</File>
<File name="calculate_score.cpp" open="0" top="0" tabpos="20">
<Cursor position="0" topLine="0" />
<File name="calculate_score.cpp" open="1" top="1" tabpos="8">
<Cursor position="288" topLine="0" />
</File>
<File name="choose_class.cpp" open="0" top="0" tabpos="15">
<Cursor position="1793" topLine="30" />
Expand All @@ -22,29 +22,29 @@
<File name="equipment.h" open="0" top="0" tabpos="18">
<Cursor position="0" topLine="0" />
</File>
<File name="game_over.cpp" open="0" top="0" tabpos="3">
<Cursor position="917" topLine="21" />
<File name="game_over.cpp" open="1" top="0" tabpos="10">
<Cursor position="917" topLine="0" />
</File>
<File name="globals.h" open="1" top="0" tabpos="3">
<Cursor position="580" topLine="5" />
<Cursor position="580" topLine="0" />
</File>
<File name="go_fishing_or_whaling.cpp" open="0" top="0" tabpos="21">
<Cursor position="2104" topLine="35" />
</File>
<File name="header.h" open="0" top="0" tabpos="2">
<Cursor position="1724" topLine="65" />
<File name="header.h" open="1" top="0" tabpos="7">
<Cursor position="602" topLine="5" />
</File>
<File name="high_seas.cpp" open="1" top="1" tabpos="2">
<Cursor position="6757" topLine="187" />
<File name="high_seas.cpp" open="1" top="0" tabpos="2">
<Cursor position="6757" topLine="127" />
</File>
<File name="landmark_reached.cpp" open="0" top="0" tabpos="23">
<Cursor position="72" topLine="33" />
</File>
<File name="load_media.cpp" open="0" top="0" tabpos="11">
<Cursor position="1987" topLine="39" />
<File name="load_media.cpp" open="1" top="0" tabpos="6">
<Cursor position="1071" topLine="29" />
</File>
<File name="main.cpp" open="1" top="0" tabpos="1">
<Cursor position="1032" topLine="21" />
<Cursor position="1032" topLine="69" />
</File>
<File name="main_menu.cpp" open="0" top="0" tabpos="10">
<Cursor position="1788" topLine="0" />
Expand All @@ -64,8 +64,8 @@
<File name="put_text_at.cpp" open="0" top="0" tabpos="8">
<Cursor position="96" topLine="0" />
</File>
<File name="random_event.cpp" open="0" top="0" tabpos="22">
<Cursor position="1557" topLine="41" />
<File name="random_event.cpp" open="1" top="0" tabpos="5">
<Cursor position="738" topLine="33" />
</File>
<File name="read_history.cpp" open="0" top="0" tabpos="17">
<Cursor position="1375" topLine="11" />
Expand All @@ -76,7 +76,7 @@
<File name="show_intro.cpp" open="0" top="0" tabpos="12">
<Cursor position="827" topLine="21" />
</File>
<File name="vinland_reached.cpp" open="0" top="0" tabpos="13">
<Cursor position="979" topLine="26" />
<File name="vinland_reached.cpp" open="1" top="0" tabpos="9">
<Cursor position="979" topLine="0" />
</File>
</CodeBlocks_layout_file>
Binary file added beiced.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion calculate_score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

int calculate_score() {

return (1000-DAYS)*DISTANCE; // kludge
return ((INVENTORY.settlers + INVENTORY.money + INVENTORY.boat_status + how_many_alive()*5)*365)/DAYS;
//return (1000-DAYS)*DISTANCE; // kludge
// double kludge for using a global for score, but oh well
}
1 change: 1 addition & 0 deletions globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ extern int PACE;
extern int RATIONS;
extern bool PAUSED;
extern int LANDMARKS;
extern bool ALREADY_FISHEDORWHALED;

#endif // GLOBALS_H_INCLUDED
1 change: 1 addition & 0 deletions header.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define IMG_PILLAGE 19
#define IMG_BUYING 20
#define IMG_REPAIR 21
#define IMG_BEICED 22

//sound enums
#define SND_OPENING 0
Expand Down
1 change: 1 addition & 0 deletions load_media.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ bool load_media() {
BITMAPS[IMG_PILLAGE] = load_bitmap("pillage.png");
BITMAPS[IMG_BUYING] = load_bitmap("blank.png");
BITMAPS[IMG_REPAIR] = load_bitmap("blank.png");
BITMAPS[IMG_BEICED] = load_bitmap("beiced.png");

//load sounds
SOUNDS[SND_MAIN_MENU] = load_sound("menu.ogg");
Expand Down
9 changes: 8 additions & 1 deletion random_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ int random_event() {
int return_code = 5; // by default, back to high seas
char temp[80]; int number;
int random_event = rand()%3+1;
if (DAYS%365 >= 182 && DAYS%365 <= 364) random_event++;

if (random_event == 1) { // becalmed
number = rand()%6+1;
Expand All @@ -17,6 +18,9 @@ int random_event() {
} else if (random_event == 3) { // BOAT FUCKING DAMAGED
number = rand()%20+1;
INVENTORY.boat_status -= number;
} else if (random_event == 4) { // ice
number = rand()%30+1;
DAYS = DAYS + number;
}

bool done = false;
Expand Down Expand Up @@ -48,14 +52,17 @@ int random_event() {
print_full_picture(BITMAPS[IMG_BECALMED]);
sprintf(temp,"Becalmed. Lose %d days.",number);
put_text_at(-1,400,temp);

} else if (random_event == 2) { //scurvy
print_full_picture(BITMAPS[IMG_SCURVY]);
put_text_at(-1,40,"Scurvy!");
} else if (random_event == 3) {
print_full_picture(BITMAPS[IMG_BOAT_DAMAGED]);
sprintf(temp,"Boat takes %d%% damage.",number);
put_text_at(-1,-1,temp);
} else if (random_event == 4) { // beiced
print_full_picture(BITMAPS[IMG_BEICED]);
sprintf(temp,"Beiced. Lose %d days.",number);
put_text_at(-1,400,temp);
}

SDL_Flip(MAIN_SCREEN);
Expand Down

0 comments on commit 0c660b5

Please sign in to comment.