Engine ready.
This commit is contained in:
5
Makefile
5
Makefile
@@ -1,5 +1,5 @@
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
OBJECTS = obj/main.o obj/game_state.o obj/in_game.o obj/main_menu.o obj/map.o obj/intro.o
|
OBJECTS = obj/main.o obj/game_state.o obj/in_game.o obj/main_menu.o obj/map.o obj/intro.o obj/game_over.o
|
||||||
TARGET = bin/cyjam
|
TARGET = bin/cyjam
|
||||||
CFLAGS = -Wall -I./include -std=c99
|
CFLAGS = -Wall -I./include -std=c99
|
||||||
LDFLAGS = -L./lib
|
LDFLAGS = -L./lib
|
||||||
@@ -29,6 +29,9 @@ obj/main_menu.o: src/main_menu.c include/main_menu.h include/game_state.h
|
|||||||
obj/intro.o: src/intro.c include/intro.h include/intro_img.h include/game_state.h
|
obj/intro.o: src/intro.c include/intro.h include/intro_img.h include/game_state.h
|
||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
|
obj/game_over.o: src/game_over.c include/game_over.h include/game_state.h
|
||||||
|
$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
obj/map.o: src/map.c include/map.h
|
obj/map.o: src/map.c include/map.h
|
||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
#ifndef STATE_CONSTS_H
|
#ifndef STATE_CONSTS_H
|
||||||
#define STATE_CONSTS_H
|
#define STATE_CONSTS_H
|
||||||
|
|
||||||
static const int DEBUG = 1;
|
static const int DEBUG = 0;
|
||||||
#define F_SEP "/"
|
#define F_SEP "/"
|
||||||
|
|
||||||
enum COLORS {
|
enum COLORS {
|
||||||
|
13
include/game_over.h
Normal file
13
include/game_over.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved.
|
||||||
|
* See the file LICENSE for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GAME_OVER_H
|
||||||
|
#define GAME_OVER_H
|
||||||
|
|
||||||
|
#include "game_state.h"
|
||||||
|
|
||||||
|
void initGOState(gs_t *);
|
||||||
|
|
||||||
|
#endif
|
@@ -39,7 +39,7 @@ player = 27 15
|
|||||||
%exit = X Y MAP_NAME MAP_X MAP_Y
|
%exit = X Y MAP_NAME MAP_X MAP_Y
|
||||||
exit = 8 25 maps/start.map 0 0
|
exit = 8 25 maps/start.map 0 0
|
||||||
exit = 9 25 maps/start.map 0 0
|
exit = 9 25 maps/start.map 0 0
|
||||||
exit = 10 24 maps/start.map 0 0
|
exit = 10 24 END 0 0
|
||||||
exit = 10 25 maps/start.map 0 0
|
exit = 10 25 maps/start.map 0 0
|
||||||
[DOORS]
|
[DOORS]
|
||||||
%door = X Y ID UNLOCKED
|
%door = X Y ID UNLOCKED
|
||||||
|
99
src/game_over.c
Normal file
99
src/game_over.c
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved.
|
||||||
|
* See the file LICENSE for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ncursesw/ncurses.h>
|
||||||
|
|
||||||
|
#include "constants.h"
|
||||||
|
#include "game_over.h"
|
||||||
|
|
||||||
|
static const char * title = "TITLE PENDING";
|
||||||
|
static const char * subtitle = "A game for the Cyberpunk Jam 2014";
|
||||||
|
static const char * aWinnerIsYou = "You have completed the scenario!";
|
||||||
|
static const char * thanks = "Thank you for playing.";
|
||||||
|
static const char * goInfo = "Press enter to return to the main menu.";
|
||||||
|
|
||||||
|
static bool enter;
|
||||||
|
|
||||||
|
void goInput();
|
||||||
|
gsname_t goUpdate();
|
||||||
|
void goRender(int, int);
|
||||||
|
|
||||||
|
void initGOState(gs_t * gs){
|
||||||
|
gs->name = GAME_OVER;
|
||||||
|
gs->input = &goInput;
|
||||||
|
gs->update = &goUpdate;
|
||||||
|
gs->render = &goRender;
|
||||||
|
}
|
||||||
|
|
||||||
|
void goInput(){
|
||||||
|
int key = 0;
|
||||||
|
|
||||||
|
key = getch();
|
||||||
|
|
||||||
|
if(key != ERR){
|
||||||
|
if(key == KEY_ENTER || key == '\n') enter = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gsname_t goUpdate(){
|
||||||
|
if(enter){
|
||||||
|
enter = FALSE;
|
||||||
|
return MENU;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GAME_OVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
void goRender(int w, int h){
|
||||||
|
int sW;
|
||||||
|
|
||||||
|
clear_screen(w, h);
|
||||||
|
|
||||||
|
/* Print the title. */
|
||||||
|
sW = strlen(title);
|
||||||
|
sW /= 2;
|
||||||
|
|
||||||
|
attron(A_BOLD);
|
||||||
|
|
||||||
|
move(1, (w / 2) - sW);
|
||||||
|
attron(COLOR_PAIR(SN_COLOR));
|
||||||
|
printw(title);
|
||||||
|
|
||||||
|
/* Print the subtitle. */
|
||||||
|
sW = strlen(subtitle);
|
||||||
|
sW /= 2;
|
||||||
|
|
||||||
|
move(2, (w / 2) - sW);
|
||||||
|
attron(COLOR_PAIR(SW_COLOR));
|
||||||
|
printw(subtitle);
|
||||||
|
|
||||||
|
attroff(A_BOLD);
|
||||||
|
|
||||||
|
/* Print the game over message. */
|
||||||
|
sW = strlen(aWinnerIsYou);
|
||||||
|
sW /= 2;
|
||||||
|
|
||||||
|
move((h / 2) - 2, (w / 2) - sW);
|
||||||
|
attron(COLOR_PAIR(GR_COLOR));
|
||||||
|
printw(aWinnerIsYou);
|
||||||
|
|
||||||
|
sW = strlen(thanks);
|
||||||
|
sW /= 2;
|
||||||
|
|
||||||
|
move((h / 2) - 1, (w / 2) - sW);
|
||||||
|
attron(COLOR_PAIR(GR_COLOR));
|
||||||
|
printw(thanks);
|
||||||
|
|
||||||
|
/* Print help. */
|
||||||
|
sW = strlen(goInfo);
|
||||||
|
sW /= 2;
|
||||||
|
|
||||||
|
move(h - 5, (w / 2) - sW);
|
||||||
|
attron(COLOR_PAIR(MN_COLOR));
|
||||||
|
printw(goInfo);
|
||||||
|
}
|
||||||
|
|
@@ -10,11 +10,13 @@
|
|||||||
#include "intro.h"
|
#include "intro.h"
|
||||||
#include "main_menu.h"
|
#include "main_menu.h"
|
||||||
#include "in_game.h"
|
#include "in_game.h"
|
||||||
|
#include "game_over.h"
|
||||||
|
|
||||||
void initStateArray(gs_t ** s){
|
void initStateArray(gs_t ** s){
|
||||||
initIntroState(&((*s)[INTRO]));
|
initIntroState(&((*s)[INTRO]));
|
||||||
initMMState(&((*s)[MENU]));
|
initMMState(&((*s)[MENU]));
|
||||||
initInGameState(&((*s)[IN_GAME]));
|
initInGameState(&((*s)[IN_GAME]));
|
||||||
|
initGOState(&((*s)[GAME_OVER]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_screen(int w, int h){
|
void clear_screen(int w, int h){
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <string.h>
|
||||||
#include <ncursesw/ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
#include <fov.h>
|
#include <fov.h>
|
||||||
|
|
||||||
@@ -140,8 +141,14 @@ gsname_t update(){
|
|||||||
if(objs[i].x == iY && objs[i].y == iX){
|
if(objs[i].x == iY && objs[i].y == iX){
|
||||||
player.x = objs[i].eX;
|
player.x = objs[i].eX;
|
||||||
player.y = objs[i].eY;
|
player.y = objs[i].eY;
|
||||||
loadMap(objs[i].target);
|
if(strcmp(objs[i].target, "END") != 0){
|
||||||
return IN_GAME;
|
loadMap(objs[i].target);
|
||||||
|
return IN_GAME;
|
||||||
|
}else{
|
||||||
|
initObjects();
|
||||||
|
loadMap("maps/start.map");
|
||||||
|
return GAME_OVER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -519,7 +526,7 @@ void setPlayerStart(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void initObjects(){
|
void initObjects(){
|
||||||
int i;
|
int i, j;
|
||||||
|
|
||||||
for(i = 0; i < MAX_OBJECTS; ++i){
|
for(i = 0; i < MAX_OBJECTS; ++i){
|
||||||
objs[i].type = NONE;
|
objs[i].type = NONE;
|
||||||
@@ -531,9 +538,11 @@ void initObjects(){
|
|||||||
objs[i].sY = 0;
|
objs[i].sY = 0;
|
||||||
objs[i].id = 0;
|
objs[i].id = 0;
|
||||||
objs[i].dId = 0;
|
objs[i].dId = 0;
|
||||||
objs[i].name[0] = '\0';
|
for(j = 0; j < MAX_STR; j++){
|
||||||
objs[i].target[0] = '\0';
|
objs[i].name[j] = '\0';
|
||||||
objs[i].dialog[0] = '\0';
|
objs[i].target[j] = '\0';
|
||||||
|
objs[i].dialog[j] = '\0';
|
||||||
|
}
|
||||||
objs[i].unlocked = 0;
|
objs[i].unlocked = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,14 +10,14 @@
|
|||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "main_menu.h"
|
#include "main_menu.h"
|
||||||
|
|
||||||
static char * title = "TITLE PENDING";
|
static const char * title = "TITLE PENDING";
|
||||||
static char * subtitle = "A game for the Cyberpunk Jam 2014";
|
static const char * subtitle = "A game for the Cyberpunk Jam 2014";
|
||||||
static char * opt1 = "New game";
|
static const char * opt1 = "New game";
|
||||||
static char * opt2 = "Replay intro";
|
static const char * opt2 = "Replay intro";
|
||||||
static char * opt3 = "Quit";
|
static const char * opt3 = "Quit";
|
||||||
static char * creds = "Designed and programmed by Miky";
|
static const char * creds = "Designed and programmed by Miky";
|
||||||
static char * info = "Press enter to select an option. Scroll with the arrow keys.";
|
static const char * info = "Press enter to select an option. Scroll with the arrow keys.";
|
||||||
static char * info2 = "Press escape while in game to return to the main menu.";
|
static const char * info2 = "Press escape while in game to return to the main menu.";
|
||||||
|
|
||||||
static int selOpt = 0;
|
static int selOpt = 0;
|
||||||
static bool uK, dK, esc, enter;
|
static bool uK, dK, esc, enter;
|
||||||
|
@@ -26,8 +26,6 @@ errcode_t readMapData(const char * file, map_cell_t *** map, int * w, int * h){
|
|||||||
int rc, i, j;
|
int rc, i, j;
|
||||||
char *end;
|
char *end;
|
||||||
|
|
||||||
fprintf(stderr, "\t%s.readMapData() : found a map.\n", __FILE__);
|
|
||||||
|
|
||||||
rc = getline(&buffer, &n, f);
|
rc = getline(&buffer, &n, f);
|
||||||
if(rc == -1){
|
if(rc == -1){
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
Reference in New Issue
Block a user