Skip to content

Commit

Permalink
parsing quad progress!
Browse files Browse the repository at this point in the history
  • Loading branch information
PixelatedLagg committed Nov 14, 2023
1 parent 0d75f3a commit 4463a99
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 8 deletions.
3 changes: 1 addition & 2 deletions levels/map.lvl
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
quad
1
q,1432423
0 0 0, 1 0 0, 1 1 0, 0 1 0
Binary file added p3d.exe
Binary file not shown.
5 changes: 5 additions & 0 deletions src/display.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#include <GL/gl.h>
#include <GL/glut.h>

#include "display.h"

#define windowWidth 1024
#define windowHeight 768

quad* quads;

//called when window init and needs to be re-painted
void display()
{
Expand Down
2 changes: 1 addition & 1 deletion src/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "quad.h"

quad* quads;
extern quad* quads;

void display();

Expand Down
1 change: 1 addition & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <GL/glu.h>
#include <stdio.h>

#include "main.h"
#include "display.h"
#include "parse.h"

Expand Down
Empty file added src/main.h
Empty file.
27 changes: 23 additions & 4 deletions src/parse.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
//parses a save file and sets global variables accordingly

#include <stdio.h>
#include <string.h>

#include "display.h"
#include "parse.h"
#include "display.h"

void parse(char** file)
void parse(char* file)
{
FILE* data = fopen(file, "r");

char readBuffer[100];

while (fgets(readBuffer, sizeof(readBuffer), data) != NULL)
{
printf("%s", readBuffer);
if (!isdigit(readBuffer[0]))
{
char *buff = (char*)malloc(10 * sizeof(char));
memcpy(buff, &readBuffer[2], strlen(readBuffer) - 2);
quads = (quad*)malloc(atoi(buff) * sizeof(quad)); //assign quad# from float in buff
free(buff);
}
int i = 0;
while (readBuffer[i] != '\n')
{

}
}
}
}

/*
string->float
float f;
f = strtof(buff, NULL);
*/
2 changes: 1 addition & 1 deletion src/parse.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef PARSE_H
#define PARSE_H

void parse(char** file);
void parse(char* file);

#endif

0 comments on commit 4463a99

Please sign in to comment.