Commit 2b9b54e5 authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

add boulder

parent 9e87cd0a
#!/bin/bash
gcc src/main.c src/game.c src/maps.c src/timehelper.c -Wall -o temp -l curses
gcc src/*.c -Wall -o temp -l curses
./temp
rm temp
#include "boulder.h"
char bould[2][3] = {"0@O", "O0@"};
void updateBoulder() {
}
void renderBoulder() {
int i, k, l;
for (i = 0; i < nbould; i++) {
for (k = 0; k < 2; k++) {
for (l = 0; l < 3; l++) {
mvprintw(2*listboulder[i].x + k + 1, 3*listboulder[i].y + l + 1,
"%c", bould[k][l]);
}
}
}
}
#ifndef _BOULDER_H
#define _BOULDER_H
#include "utils.h"
typedef struct {
int x, y;
int falling;
} boulder;
boulder listboulder[500];
int nbould;
void updateBoulder();
void renderBoulder();
#endif
#include "entity.h"
#ifndef _ENTITY_H
#define _ENTITY_H
#include "utils.h"
typedef struct {
FILE *sprite;
unsigned char grid[WIDTH][HEIGHT];
} map;
typedef struct {
int x, y;
int dir;
} rockford;
#endif
#include "maps.h"
char empty[2][3] = {" ", " "};
//char empty[2][3] = {" ", " "};
char steel[2][3] = {"ETE", "ETE"};
char dirt[2][3] = {"-_-", "-_-"};
char wall[2][3] = {"#H#", "H#H"};
char ext[2][3] = {"ETE", "ETE"};
char rockf[2][3] = {" o ", " A "};
char boulder[2][3] = {"0@O", "O0@"};
char diamond[2][3] = {"uuu", "\\o/"};
char diamond[2][3] = {"/-\\", "\\-/"};
char butterfly[2][3] = {"\\_/", "/ \\"};
char input[WIDTH];
boulder aux;
void readFileMap(map *m, char *path) {
int i, j;
nbould = 0;
m->sprite = fopen("./sprites/map1.txt", "r");
for (i = 0; i < HEIGHT; i++) {
fscanf(m->sprite, "%s", input);
for (j = 0; j < WIDTH; j++)
for (j = 0; j < WIDTH; j++) {
if (input[j] == '6') {
aux.x = i;
aux.y = j;
aux.falling = false;
listboulder[nbould++] = aux;
}
m->grid[j][i] = input[j];
}
}
fclose(m->sprite);
}
......@@ -31,11 +39,6 @@ void renderMap(map *m) {
for (i = 0; i < WIDTH; i++) {
for (j = 0; j < HEIGHT; j++) {
switch (m->grid[i][j]) {
case('0'):
for (k = 0; k < 2; k++)
for (l = 0; l < 3; l++)
mvprintw(2*j+k+1, 3*i+l+1, "%c", empty[k][l]);
break;
case('1'):
for (k = 0; k < 2; k++)
for (l = 0; l < 3; l++)
......@@ -61,11 +64,6 @@ void renderMap(map *m) {
for (l = 0; l < 3; l++)
mvprintw(2*j+k+1, 3*i+l+1, "%c", rockf[k][l]);
break;
case('6'):
for (k = 0; k < 2; k++)
for (l = 0; l < 3; l++)
mvprintw(2*j+k+1, 3*i+l+1, "%c", boulder[k][l]);
break;
case('7'):
for (k = 0; k < 2; k++)
for (l = 0; l < 3; l++)
......@@ -80,4 +78,5 @@ void renderMap(map *m) {
}
}
renderBoulder();
}
#ifndef _MAPS_H
#define _MAPS_H
#include "utils.h"
#include "boulder.h"
typedef struct {
FILE *sprite;
unsigned char grid[WIDTH][HEIGHT];
} map;
void readFileMap();
void updateMap(map *m);
......
#include "rockford.h"
int updateRockford(rockford *player) {
void updateRockford(rockford *player) {
}
......
......@@ -2,7 +2,12 @@
#define _ROCKFORD_H
#include "utils.h"
int updateRockford(rockford *player);
typedef struct {
int x, y;
int dir;
} rockford;
void updateRockford(rockford *player);
void renderRockford(rockford *player);
#endif
......@@ -7,7 +7,6 @@
#define WIDTH 40
#define HEIGHT 22
#include "entity.h"
#define true 1
#define false 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment