Skip to content

Instantly share code, notes, and snippets.

@loriopatrick
Created May 20, 2014 20:18
Show Gist options
  • Save loriopatrick/209033c1c6611ee1d1c3 to your computer and use it in GitHub Desktop.
Save loriopatrick/209033c1c6611ee1d1c3 to your computer and use it in GitHub Desktop.
I think I'm going to get more into C.
#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