Created
December 3, 2013 09:02
-
-
Save anonymous/7766226 to your computer and use it in GitHub Desktop.
Files and error output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Engine.h" | |
#include "Structures.h" | |
void handleKeys(int ch, struct Player *human) { | |
clear(); | |
if(ch == 'j') { | |
if(human->playerx > 0) { | |
human->playerx--; | |
mvprintw(11, 0, "Key left pressed"); | |
} | |
} | |
if(ch == 'l') { | |
if(human->playerx < 100) { | |
human->playerx++; | |
mvprintw(11, 0, "Key right pressed"); | |
} | |
} | |
if(ch == 'i') { | |
if(human->playery > 0) { | |
human->playery--; | |
mvprintw(11, 0, "Key up pressed"); | |
} | |
} | |
if(ch == 'k') { | |
if(human->playerx < 100){ | |
human->playery++; | |
mvprintw(11, 0, "Key down pressed"); | |
} | |
} | |
attron(COLOR_PAIR(9)); | |
mvaddch(human->playery, human->playerx, '@'); | |
attroff(COLOR_PAIR(9)); | |
refresh(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void handleKeys(int ch, struct Player *human); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <curses.h> | |
#include "Structures.h" | |
#include "Engine.c" | |
struct Player human; | |
int main(int argc, char const *argv[]) | |
{ | |
//Set up curses | |
initscr(); | |
start_color(); | |
init_pair(0, COLOR_RED, COLOR_BLACK); | |
init_pair(9, COLOR_YELLOW, COLOR_BLACK); | |
cbreak(); | |
noecho(); | |
//Set up the player | |
human.playerx = 5; | |
human.playery = 5; | |
//Draw the player | |
attron(COLOR_PAIR(9)); | |
mvaddch(human.playery, human.playerx, '@'); | |
attroff(COLOR_PAIR(9)); | |
//As long as q is not pressed, play | |
int ch = 0; | |
while(ch != 'q') { | |
ch = getch(); | |
handleKeys(ch, &human); | |
refresh(); | |
} | |
mvprintw(11, 0, "You pressed q to quit"); | |
mvprintw(12, 0, "Press any key to exit"); | |
getch(); | |
endwin(); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct Player{ | |
int playerx; | |
int playery; | |
} Player; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In file included from Main.c:3: | |
In file included from ./Engine.c:2: | |
./Structures.h:1:16: error: redefinition of 'Player' | |
typedef struct Player{ | |
^ | |
./Structures.h:1:16: note: previous definition is here | |
typedef struct Player{ | |
^ | |
In file included from Main.c:3: | |
In file included from ./Engine.c:2: | |
./Structures.h:4:3: error: typedef redefinition with different types | |
('struct Player' (aka 'Player') vs 'struct Player') | |
} Player; | |
^ | |
./Structures.h:4:3: note: previous definition is here | |
} Player; | |
^ | |
Main.c:20:10: error: member reference type 'struct Player *' is a pointer; maybe | |
you meant to use '->'? | |
human.playerx = 5; | |
~~~~~^ | |
-> | |
Main.c:21:10: error: member reference type 'struct Player *' is a pointer; maybe | |
you meant to use '->'? | |
human.playery = 5; | |
~~~~~^ | |
-> | |
Main.c:25:18: error: member reference type 'struct Player *' is a pointer; maybe | |
you meant to use '->'? | |
mvaddch(human.playery, human.playerx, '@'); | |
~~~~~^ | |
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/curses.h:1082:43: note: | |
expanded from macro 'mvaddch' | |
#define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch) | |
^ | |
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/curses.h:1061:42: note: | |
expanded from macro 'mvwaddch' | |
#define mvwaddch(win,y,x,ch) (wmove(win,y,x) == ERR ? ERR : w... | |
^ | |
Main.c:25:33: error: member reference type 'struct Player *' is a pointer; maybe | |
you meant to use '->'? | |
mvaddch(human.playery, human.playerx, '@'); | |
~~~~~^ | |
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/curses.h:1082:45: note: | |
expanded from macro 'mvaddch' | |
#define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch) | |
^ | |
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/curses.h:1061:44: note: | |
expanded from macro 'mvwaddch' | |
#define mvwaddch(win,y,x,ch) (wmove(win,y,x) == ERR ? ERR : w... | |
^ | |
Main.c:33:24: warning: incompatible pointer types passing 'struct Player **' to | |
parameter of type 'struct Player *'; remove & | |
[-Wincompatible-pointer-types] | |
handleKeys(ch, &human); | |
^~~~~~ | |
./Engine.c:5:40: note: passing argument to parameter 'human' here | |
void handleKeys(int ch, struct Player *human) { | |
^ | |
1 warning and 6 errors generated. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment