Created
May 20, 2014 20:18
-
-
Save loriopatrick/209033c1c6611ee1d1c3 to your computer and use it in GitHub Desktop.
I think I'm going to get more into C.
This file contains hidden or 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 <stdio.h> | |
typedef struct { | |
float x; | |
float y; | |
char* name; | |
} Player; | |
typedef void (*PlayerCommand)(Player* player); | |
void MovePlayer(Player* player) { | |
player->x += 2; | |
printf("I moved %s, he is now at (%f, %f)\n", player->name, player->x, player->y); | |
} | |
int main(int args, char** argv) { | |
Player player = {0, 0, "Bob"}; | |
PlayerCommand command = MovePlayer; | |
command(&player); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment