Convert aquatinspitz to C.

This commit is contained in:
Jonas 'Sortie' Termansen 2016-02-28 22:11:39 +01:00
parent e004de8827
commit f0470869a9
2 changed files with 17 additions and 12 deletions

View File

@ -5,8 +5,10 @@ include ../build-aux/version.mak
include ../build-aux/dirs.mak
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
CFLAGS?=$(OPTLEVEL)
CXXFLAGS?=$(OPTLEVEL)
CFLAGS:=$(CFLAGS) -Wall -Wextra
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti
BINARIES:=\
@ -23,8 +25,11 @@ install: all
mkdir -p $(DESTDIR)$(BINDIR)
install $(BINARIES) $(DESTDIR)$(BINDIR)
%: %.c
$(CC) -std=gnu11 $(CFLAGS) $(CPPFLAGS) $< -o $@ $(LIBS)
%: %.cpp
$(CXX) -std=gnu++11 $(CPPFLAGS) $(CXXFLAGS) $< -o $@ $(LIBS)
$(CXX) -std=gnu++11 $(CXXFLAGS) $(CPPFLAGS) $< -o $@ $(LIBS)
clean:
rm -f $(BINARIES) *.o

View File

@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
aquatinspitz.cpp
aquatinspitz.c
Aqua tin spitz!
*******************************************************************************/
@ -40,13 +40,13 @@
#include <dispd.h>
// Utility global variables every game will need.
bool game_running = true;
size_t game_width = 1280;
size_t game_height = 720;
const size_t MAX_KEY_NUMBER = 512UL;
bool keys_down[MAX_KEY_NUMBER] = { false };
bool keys_pending[MAX_KEY_NUMBER] = { false };
struct timespec key_handled_last[MAX_KEY_NUMBER];
static bool game_running = true;
static size_t game_width = 1280;
static size_t game_height = 720;
#define MAX_KEY_NUMBER 512
static bool keys_down[MAX_KEY_NUMBER];
static bool keys_pending[MAX_KEY_NUMBER];
static struct timespec key_handled_last[MAX_KEY_NUMBER];
// Utility functions every game will need.
bool pop_is_key_just_down(int abskbkey);
@ -74,10 +74,10 @@ struct enemy
};
#define NUM_ENEMIES 256
struct enemy enemies[NUM_ENEMIES];
static struct enemy enemies[NUM_ENEMIES];
// Prepare the game state for the first round.
void init()
void init(void)
{
player.x = game_width / 2;
player.y = game_height / 2;
@ -314,7 +314,7 @@ bool pop_is_key_just_down(int abskbkey)
}
// Read input from the keyboard.
void input()
void input(void)
{
// Read the keyboard input from the user.
unsigned termmode = TERMMODE_KBKEY | TERMMODE_SIGNAL | TERMMODE_NONBLOCK;