aboutsummaryrefslogblamecommitdiffstats
path: root/src/extern.h
blob: 482b9edd78f0757fc8b5cfc96cd5c951b89b4bd7 (plain) (tree)





















































                                                              
/*
 * Copyright (c) 2019-2020, yzrh <yzrh@noema.org>
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>

#include "renderer.h"
#include "game.h"
#include "input.h"

bool collision(int *a, int *b);
bool collision_block(int *a, int *b);
bool collision_bound(float x, float y, Snake_Text *message);

void draw_clear(SDL_Renderer *renderer);
void draw_colour(SDL_Renderer *renderer, Snake_Colour colour);
void draw_text(SDL_Renderer *renderer, TTF_Font *font,
	int text_x, int text_y, char *text,
	bool centre, bool select, SDL_Color fg, SDL_Color bg,
	Snake_Text *message);
void draw_wall(SDL_Renderer *renderer);
void draw_snake(SDL_Renderer *renderer, Snake_Pos **snake);
void draw_fruit(SDL_Renderer *renderer, int *fruit);
void draw_pipe(SDL_Renderer *renderer, Snake_Pos **pipe);

void game_snake_init(Snake_Pos **snake, int dx);
void game_snake_move(Snake_Pos **snake0, Snake_Pos **snake1,
	Snake_Input *head, bool lawi, int *legal);
void game_snake_grow(Snake_Pos **snake);
void game_fruit(int *fruit, Snake_Pos **snake);
void game_snake_fall(Snake_Pos **snake, bool norm, int speed);
void game_pipe_init(Snake_Pos **pipe);
void game_pipe_move(Snake_Pos **pipe);
void game_pipe_add(Snake_Pos **pipe);
void game_pipe_del(Snake_Pos **pipe);
void game_pipe_pos(Snake_Pos **pipe, int *state);
void game_pipe_bound(Snake_Pos **pipe, int *pos);

void input_keyboard(SDL_Keycode sym, Snake_Input *code);
void input_controller(uint8_t button, Snake_Input *code);
void input_gpio(int gpio, uint8_t *button);

#ifdef GPIO

int gpio_export(int pin);
int gpio_unexport(int pin);
int gpio_config(int pin, int direction, int interrupt);
int gpio_write(int pin, int value);
int gpio_read(int pin);

#endif /* GPIO */