Cleaner code, slight vector progress. dgray still doesn't work and I don't know why

This commit is contained in:
KikooDX 2020-09-10 17:58:12 +02:00
parent 97b60ce24f
commit c850984a72
8 changed files with 37 additions and 17 deletions

BIN
JTMM2.g3a Normal file

Binary file not shown.

View File

@ -1,7 +1,10 @@
#ifndef _DEF_INIT
#define _DEF_INIT
#ifdef FX9860G
#include <gint/gray.h>
#endif /* FX9860G */
void init();
#endif

16
include/vec.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef _DEF_VEC2D
#define _DEF_VEC2D
typedef struct Vec
{
int x;
int y;
} Vec;
/* apply a force on a vector */
void vec_add(Vec *vector, Vec force);
/* apply the opposite of a force on a vector */
void vec_sub(Vec *vector, Vec force);
#endif

View File

@ -1,10 +0,0 @@
#ifndef _DEF_VEC2D
#define _DEF_VEC2D
struct Vec2D
{
int x;
int y;
};
#endif

View File

@ -1,9 +1,10 @@
#include "init.h"
#include <gint/gray.h>
void init()
{
#ifdef FX9860G
gray_start();
dgray(DGRAY_ON);
#endif /* FX9860G */
#ifdef FXCG50
#endif /* FXCG50*/

View File

@ -1,16 +1,14 @@
#include <gint/display.h>
#include <gint/keyboard.h>
#include "init.h"
#include "vec2d.h"
#include "vec.h"
int main(void)
{
init(); /* initialise gint */
struct Vec2D vector_test = {
.x = 20,
.y = -50
};
Vec vector_test = {20, -50};
vec_add(&vector_test, (Vec){5, -10});
dclear(C_WHITE);
dprint(1, 1, C_BLACK, "vector_test: x = %d, y = %d", vector_test.x, vector_test.y);
dupdate();

13
src/vec.c Normal file
View File

@ -0,0 +1,13 @@
#include "vec.h"
void vec_add(Vec *vector, Vec force)
{
vector->x += force.x;
vector->y += force.y;
}
void vec_sub(Vec *vector, Vec force)
{
vector->x -= force.x;
vector->y -= force.y;
}

View File

@ -1 +0,0 @@
#include "vec2d.h"