1
1
Fork 0
Browse Source

fixed linking problem

thread-physics
alistair 4 years ago
parent
commit
4f980770e1
  1. 4
      draw.c
  2. 4
      draw.h
  3. 18
      game.c
  4. 36
      game.h
  5. 3
      garbo.c
  6. 4
      garbo.h
  7. 2
      main.c

4
draw.c

@ -1,6 +1,9 @@ @@ -1,6 +1,9 @@
#include "draw.h"
#include "vect.h"
Vect viewport_pos;
int width, height;
/* generic rendering functions */
int MAX_ONSCREEN_OBJECTS = 99;
@ -338,5 +341,4 @@ void redraw_buffer(SDL_Renderer * ren) { @@ -338,5 +341,4 @@ void redraw_buffer(SDL_Renderer * ren) {
/*SDL_RenderDrawPoints(ren, row, numpixels[i]);*/
/*}*/
}

4
draw.h

@ -29,8 +29,8 @@ void add_to_view(draw_type kind, void * object); @@ -29,8 +29,8 @@ void add_to_view(draw_type kind, void * object);
void redraw_buffer(SDL_Renderer * ren);
Vect viewport_pos;
extern Vect viewport_pos;
int width, height;
extern int width, height;
#endif

18
game.c

@ -1,9 +1,24 @@ @@ -1,9 +1,24 @@
#include "game.h"
player_st *glob_player;
/* array of all the things in the world and their kinds */
world_thing *world;
int things_in_world;
int world_size;
void startgame(SDL_Renderer * ren) ;
void process_keydown(SDL_Keysym key);
void process_keyup(SDL_Keysym key);
void step(int interval);
player_st player;
// local
void set_motor_newtons(Body *thing, int motorID, double x, double y);
void set_motor_max_velocity(Body *thing, int motorID, double max);
void get_new_physics(Body **phys);
// move the collision poly to the position of the player
@ -19,7 +34,6 @@ void default_update_collision_poly(Body *body) { @@ -19,7 +34,6 @@ void default_update_collision_poly(Body *body) {
}
// collision poly size must be 2x shape_size + 1
void cast_update_collision_poly(Body *body) {
for (int i=0; i < body->collision_shape_size; i++) {

36
game.h

@ -3,11 +3,11 @@ @@ -3,11 +3,11 @@
#include <stdbool.h>
#include <stdint.h>
#include <math.h>
#include "vect.h"
#ifndef _DEFGAME
#define _DEFGAME
#include "vect.h"
#include "garbo.h"
#include "draw.h"
@ -21,7 +21,8 @@ enum world_thing_kind { @@ -21,7 +21,8 @@ enum world_thing_kind {
PLAYER_W,
STATIC_WALL_W,
FLOOR,
CEILING
CEILING,
PROJECTILE
};
// used to exert a force on an object
@ -143,6 +144,12 @@ typedef struct { @@ -143,6 +144,12 @@ typedef struct {
int numPolys;
} Floor;
typedef struct Projectile {
Body *physics;
void*(*on_collision)(struct Projectile*);
void*(*on_step)(struct Projectile*);
} Projectile;
typedef struct {
enum world_thing_kind kind;
int nid;
@ -152,24 +159,23 @@ typedef struct { @@ -152,24 +159,23 @@ typedef struct {
player_st *player;
Wall *wall;
Floor *floor;
Projectile *projectile;
};
} world_thing;
/* array of all the things in the world and their kinds */
world_thing *world;
int things_in_world;
int world_size;
void startgame(SDL_Renderer * ren) ;
void process_keydown(SDL_Keysym key);
void process_keyup(SDL_Keysym key);
// add a motor to the world
void add_motor(Body *thing, double x, double y);
void step(int interval);
/* array of all the things in the world and their kinds */
extern world_thing *world;
player_st player;
extern int things_in_world;
extern int world_size;
extern void startgame(SDL_Renderer * ren) ;
extern void process_keydown(SDL_Keysym key);
extern void process_keyup(SDL_Keysym key);
extern void step(int interval);
extern player_st player;
void add_motor(Body *thing, double x, double y);
#endif

3
garbo.c

@ -1,5 +1,8 @@ @@ -1,5 +1,8 @@
#include "garbo.h"
static sdl_abstract cleanup_queue[100];
static int cleanup_queue_length = 0;
void queue_for_cleanup(void * SDL_thing, sdl_types kind) {
// add item to queue for later cleanup
// TODO: support multiple cleanup queues

4
garbo.h

@ -27,8 +27,6 @@ typedef struct { @@ -27,8 +27,6 @@ typedef struct {
thing_for_cleanup thing;
} sdl_abstract;
static sdl_abstract cleanup_queue[100];
static int cleanup_queue_length = 0;
/* Function prototypes */
@ -40,5 +38,3 @@ void empty_cleanup_queue(void); @@ -40,5 +38,3 @@ void empty_cleanup_queue(void);
#endif

2
main.c

@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
const int screen_width = 800;
const int screen_height = 600;
struct SDL_Window* make_window(void) {
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
printf("error initializing SDL: %s\n", SDL_GetError());
@ -98,7 +97,6 @@ int main () { @@ -98,7 +97,6 @@ int main () {
}
empty_cleanup_queue();
printf("Cleanup queue length: %d\n", cleanup_queue_length);
logwrite(DEBUG, "Emptied cleanup queue\n");
return 0;
}

Loading…
Cancel
Save