Created player files, draw a pixel on screen for test

This commit is contained in:
KikooDX 2020-09-11 12:01:24 +02:00
parent 4100c2b5fb
commit a496f428ce
4 changed files with 30 additions and 6 deletions

14
include/player.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef _DEF_PLAYER
#define _DEF_PLAYER
#include "vec.h"
typedef struct Player
{
Vec position;
} Player;
/* draw the player */
void draw_player(Player *player);
#endif

View File

@ -1,5 +1,5 @@
#ifndef _DEF_VEC2D
#define _DEF_VEC2D
#ifndef _DEF_VEC
#define _DEF_VEC
typedef struct Vec
{

View File

@ -2,16 +2,19 @@
#include <gint/keyboard.h>
#include "init.h"
#include "vec.h"
#include "player.h"
int main(void)
{
init(); /* initialize gint */
Vec vector_test = {20, -50};
vec_add(&vector_test, (Vec){5.25, -10.5});
/* create player */
Player player = {
.position = (Vec){32, 32}
};
dclear(C_WHITE);
dtext(1, 1, C_BLACK, "vector_test:");
dprint(1, 8, C_BLACK, "x = %d, y = %d", (int)(vector_test.x), (int)(vector_test.y));
draw_player(&player);
dupdate();
getkey();

7
src/player.c Normal file
View File

@ -0,0 +1,7 @@
#include "player.h"
#include <gint/display.h>
void draw_player(Player *player)
{
dpixel(player->position.x, player->position.y, C_BLACK);
}