Start user file
This commit is contained in:
parent
02d23048dc
commit
c0f5e5cf5b
8 changed files with 83 additions and 33 deletions
17
assets.h
17
assets.h
|
@ -1,8 +1,12 @@
|
||||||
#ifndef _LCR_ASSETS_H
|
#ifndef _LCR_ASSETS_H
|
||||||
#define _LCR_ASSETS_H
|
#define _LCR_ASSETS_H
|
||||||
|
|
||||||
/**
|
/*
|
||||||
Assets embedded in source code.
|
Licar: assets
|
||||||
|
|
||||||
|
This file holds assets, resources and other bigger pieces of data that will be
|
||||||
|
compiled right into the executable. This is so that for a minimal version of
|
||||||
|
the game a filesystem is not needed.
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
- All images are 64x64, stored in an indexed mode (8bits pery pixel), the
|
- All images are 64x64, stored in an indexed mode (8bits pery pixel), the
|
||||||
|
@ -84,16 +88,7 @@ static const char *LCR_internalDataFile =
|
||||||
":-k5k0 :f5120"
|
":-k5k0 :f5120"
|
||||||
" map end "
|
" map end "
|
||||||
|
|
||||||
"#Mmap2;4321 1 :*H1k0J :,s0s0 :fd190 "
|
|
||||||
"#Rrep1;testmap;482f70f9 00000188:00c1:0089:0111:00b9:0091:0109:0028:0050:00c1:0093:0030:00d1:0069:0041:0020:0071:0013:0012:0023:0022:0050:0032:0020:0022:0060:0024:00bc:0044"
|
"#Rrep1;testmap;482f70f9 00000188:00c1:0089:0111:00b9:0091:0109:0028:0050:00c1:0093:0030:00d1:0069:0041:0020:0071:0013:0012:0023:0022:0050:0032:0020:0022:0060:0024:00bc:0044"
|
||||||
"#Mmap3;4321 1 :*H1k0J :,s0s0 :fd190 "
|
|
||||||
"#Mmap4;4321 1 :*H1k0J :,s0s0 :fd190 "
|
|
||||||
"#Mmap5;4321 1 :*H1k0J :,s0s0 :fd190 "
|
|
||||||
"#Mmap6;4321 1 :*H1k0J :,s0s0 :fd190 "
|
|
||||||
"#Mmap7;4321 1 :*H1k0J :,s0s0 :fd190 "
|
|
||||||
"#Mmap8;4321 1 :*H1k0J :,s0s0 :fd190 "
|
|
||||||
"#Mmap9;4321 1 :*H1k0J :,s0s0 :fd190 "
|
|
||||||
"#Mmap10;4321 1 :*H1k0J :,s0s0 :fd190 "
|
|
||||||
;
|
;
|
||||||
|
|
||||||
#define LCR_IMAGE_SIZE 64 ///< one-dimension resolution of bitmap image
|
#define LCR_IMAGE_SIZE 64 ///< one-dimension resolution of bitmap image
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#define LCR_SETTING_LOG_LEVEL 2
|
#define LCR_SETTING_LOG_LEVEL 2
|
||||||
|
|
||||||
|
#define DATA_FILE_NAME "data"
|
||||||
|
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
|
||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
|
@ -12,15 +14,44 @@ SDL_Surface *screenSurface;
|
||||||
uint16_t screen[LCR_SETTING_RESOLUTION_X * LCR_SETTING_RESOLUTION_Y];
|
uint16_t screen[LCR_SETTING_RESOLUTION_X * LCR_SETTING_RESOLUTION_Y];
|
||||||
|
|
||||||
FILE *musicFile = 0;
|
FILE *musicFile = 0;
|
||||||
|
FILE *dataFile = 0;
|
||||||
|
|
||||||
char LCR_getNextDataFileChar(void)
|
char LCR_getNextDataFileChar(void)
|
||||||
{
|
{
|
||||||
return 0;
|
if (!dataFile)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int c = fgetc(dataFile);
|
||||||
|
|
||||||
|
if (c == EOF)
|
||||||
|
{
|
||||||
|
rewind(dataFile);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LCR_appendDataStr(const char *str)
|
void LCR_appendDataStr(const char *str)
|
||||||
{
|
{
|
||||||
return;
|
if (!dataFile)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (*str == 0)
|
||||||
|
rewind(dataFile);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fclose(dataFile);
|
||||||
|
|
||||||
|
dataFile = fopen(DATA_FILE_NAME,"a");
|
||||||
|
|
||||||
|
if (dataFile)
|
||||||
|
{
|
||||||
|
fprintf(dataFile,"%s",str);
|
||||||
|
fclose(dataFile);
|
||||||
|
dataFile = fopen(DATA_FILE_NAME,"r");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void audioFillCallback(void *userdata, uint8_t *s, int l)
|
void audioFillCallback(void *userdata, uint8_t *s, int l)
|
||||||
|
@ -87,6 +118,11 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
uint8_t running = 1;
|
uint8_t running = 1;
|
||||||
|
|
||||||
|
dataFile = fopen(DATA_FILE_NAME,"r");
|
||||||
|
|
||||||
|
if (!dataFile)
|
||||||
|
LCR_log("couldn't open data file");
|
||||||
|
|
||||||
LCR_log("initializing game");
|
LCR_log("initializing game");
|
||||||
LCR_gameInit();
|
LCR_gameInit();
|
||||||
|
|
||||||
|
@ -171,6 +207,9 @@ int main(int argc, char *argv[])
|
||||||
if (musicFile)
|
if (musicFile)
|
||||||
fclose(musicFile);
|
fclose(musicFile);
|
||||||
|
|
||||||
|
if (dataFile)
|
||||||
|
fclose(dataFile);
|
||||||
|
|
||||||
SDL_PauseAudio(1);
|
SDL_PauseAudio(1);
|
||||||
SDL_CloseAudio();
|
SDL_CloseAudio();
|
||||||
|
|
||||||
|
|
20
game.h
20
game.h
|
@ -1,15 +1,19 @@
|
||||||
#ifndef _LCR_GAME_H
|
#ifndef _LCR_GAME_H
|
||||||
#define _LCR_GAME_H
|
#define _LCR_GAME_H
|
||||||
|
|
||||||
/**
|
/*
|
||||||
game: this file implements the backend of a complete, actually playable
|
Licar: game module
|
||||||
game, and is meant to be included and used by specific frontends (which
|
|
||||||
will handle each platform's hardware details and I/O).
|
|
||||||
|
|
||||||
TODO: more documentation
|
This file implements the backend of a complete, actually playable game with
|
||||||
|
graphics, sound etc., and is meant to be included and used by specific
|
||||||
|
frontends (which will handle each platform's hardware details and I/O). See
|
||||||
|
the frontend info below for help with porting the game to a new platform.
|
||||||
|
|
||||||
|
The code uses LCR_ (or _LCR) prefix as a kind of namespace preventing
|
||||||
|
collision with 3rd party identifiers.
|
||||||
|
|
||||||
UNITS: There are various kinds of units used to ensure independence of the
|
UNITS: There are various kinds of units used to ensure independence of the
|
||||||
game modules. Here is a summary:
|
modules. Here is a summary:
|
||||||
|
|
||||||
- LCR_GameUnit: data type, abstract unit of the game (racing module). One map
|
- LCR_GameUnit: data type, abstract unit of the game (racing module). One map
|
||||||
square is LCR_GAME_UNITs long, a full angle is also LCR_GAME_UNITs.
|
square is LCR_GAME_UNITs long, a full angle is also LCR_GAME_UNITs.
|
||||||
|
@ -27,7 +31,7 @@
|
||||||
their coordinate system (X right, Y up, Z forward) and rotations (Euler
|
their coordinate system (X right, Y up, Z forward) and rotations (Euler
|
||||||
angles, by Z, then by X, then Y).
|
angles, by Z, then by X, then Y).
|
||||||
|
|
||||||
RESOURCE FILE: The game uses so called data file to store various resources,
|
DATA FILE: The game uses so called data file to store various resources,
|
||||||
mainly maps and replays. There is considered to be one abstract global file
|
mainly maps and replays. There is considered to be one abstract global file
|
||||||
which is just a long text string. Internally the global file is composed of
|
which is just a long text string. Internally the global file is composed of
|
||||||
a hardcoded internal data file string (stored in assets) with very basic maps,
|
a hardcoded internal data file string (stored in assets) with very basic maps,
|
||||||
|
@ -54,7 +58,7 @@
|
||||||
#define LCR_KEYS_TOTAL 6
|
#define LCR_KEYS_TOTAL 6
|
||||||
|
|
||||||
/*
|
/*
|
||||||
FOR FRONTENDS:
|
FOR FRONTENDS (porting to other platforms):
|
||||||
- Implement the below described functions according to their description.
|
- Implement the below described functions according to their description.
|
||||||
- Implement the main program and game loop.
|
- Implement the main program and game loop.
|
||||||
- Call the below described functions as described.
|
- Call the below described functions as described.
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#ifndef _LCR_GENERAL_H
|
#ifndef _LCR_GENERAL_H
|
||||||
#define _LCR_GENERAL_H
|
#define _LCR_GENERAL_H
|
||||||
|
|
||||||
/**
|
/*
|
||||||
General resources for all modules.
|
Licar: general
|
||||||
|
|
||||||
|
This file holds general definitions used by all modules.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
6
map.h
6
map.h
|
@ -1,8 +1,10 @@
|
||||||
#ifndef _LCR_MAP
|
#ifndef _LCR_MAP
|
||||||
#define _LCR_MAP
|
#define _LCR_MAP
|
||||||
|
|
||||||
/**
|
/*
|
||||||
The map (track) module for Licar.
|
Licar: map module
|
||||||
|
|
||||||
|
This implements maps (i.e. tracks, levels, ...).
|
||||||
|
|
||||||
Map coordinates/size:
|
Map coordinates/size:
|
||||||
- map size is 64x64x64 blocks
|
- map size is 64x64x64 blocks
|
||||||
|
|
9
racing.h
9
racing.h
|
@ -1,9 +1,12 @@
|
||||||
#ifndef _LCR_RACING_H
|
#ifndef _LCR_RACING_H
|
||||||
#define _LCR_RACING_H
|
#define _LCR_RACING_H
|
||||||
|
|
||||||
/**
|
/*
|
||||||
Racing module: implements the racing physics and logic as well as replays and
|
Licar: racing module
|
||||||
other related things.
|
|
||||||
|
This implements the racing physics and logic as well as replays and other
|
||||||
|
related things. It's possible to use this module alone if one wants to
|
||||||
|
implement a program that doesn't need graphics, I/O etc.
|
||||||
|
|
||||||
Some comments:
|
Some comments:
|
||||||
- Replays are internally stored as follows: the replay consists of 16 bit
|
- Replays are internally stored as follows: the replay consists of 16 bit
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
#ifndef _LCR_RENDERER_H
|
#ifndef _LCR_RENDERER_H
|
||||||
#define _LCR_RENDERER_H
|
#define _LCR_RENDERER_H
|
||||||
|
|
||||||
/**
|
/*
|
||||||
Renderer: implements 3D and 2D rendering.
|
Licar: renderer module
|
||||||
|
|
||||||
|
This implements 3D and 2D rendering. It should be possible to replace this
|
||||||
|
module with another one to get let's say a GPU accelerated OpenGL renderer.
|
||||||
|
|
||||||
Some comments:
|
Some comments:
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#ifndef _LCR_SETTINGS_H
|
#ifndef _LCR_SETTINGS_H
|
||||||
#define _LCR_SETTINGS_H
|
#define _LCR_SETTINGS_H
|
||||||
|
|
||||||
/**
|
/*
|
||||||
Settings file, values here may be changed by the user or overriden by frontend
|
Licar: settings
|
||||||
before compilation.
|
|
||||||
|
Compile times settings file for all modules, values here may be changed by the
|
||||||
|
user or overriden by frontend before compilation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LCR_SETTING_RESOLUTION_X
|
#ifndef LCR_SETTING_RESOLUTION_X
|
||||||
|
|
Loading…
Reference in a new issue