|
|
1 tahun lalu | |
|---|---|---|
| .. | ||
| .gitsubtree | 2 tahun lalu | |
| LICENSE | 2 tahun lalu | |
| README.md | 2 tahun lalu | |
| card.c | 1 tahun lalu | |
| card.h | 1 tahun lalu | |
| card_graphics.png | 2 tahun lalu | |
| dml.c | 1 tahun lalu | |
| dml.h | 1 tahun lalu | |
| menu.c | 1 tahun lalu | |
| menu.h | 1 tahun lalu | |
| queue.c | 1 tahun lalu | |
| queue.h | 1 tahun lalu | |
| ui.c | 1 tahun lalu | |
| ui.h | 1 tahun lalu | |
A collection of methods my games are using.
Extra methods for graphics. It can read/write/copy anything from the screen, create a buffer that you can swap with the one inside the canvas object and every flipper draw call should work with it.
Call this at the end of your program
ui_cleanup();
test_pixel(canvas_buffer, pixel_x, pixel_y, screen_width)uint8_t * result=image_data(canvas, icon);uint32_t result=pixel_index(x, y)draw_icon_clip(canvas, icon, image_x, image_y, screen_x, screen_y, width, height, draw_mode)draw_icon_clip_flipped(canvas, icon, image_x, image_y, screen_x, screen_y, width, height, draw_mode)draw_rounded_box(canvas, x, y, width, heigth, draw_mode)draw_rounded_box_frame(canvas, x, y, width, heigth, draw_mode)draw_rectangle(canvas, x, y, width, heigth, draw_mode)invert_rectangle(canvas, x, y, width, height)invert_shape(canvas, image, x, y, width, height)read_pixel(canvas, x, y)set_pixel(canvas, x, y, draw_mode)set_pixel(canvas, x1, y1, x2, y1, draw_mode)in_screen(x, y)in_screen(x, y)get_buffer(canvas)make_buffer()clone_buffer(source_buffer, result_buffer)Some extra math functionality.
Vector result = vector_add(a, b);Vector result = vector_sub(a, b);Vector result = vector_mul_components(a, b);Vector result = vector_div_components(a, b);float result = vector_magnitude(a);Vector result = vector_normalized(a);Vector result = vector_distance(a, b);float result = vector_distance(a, b);float result = lerp(start_value, end_value, time);Vector result = lerp(start_vector, end_vector, time);Vector result = quadratic_2d(start_vector, control_vector, end_vector, time);min(a,b);max(a,b);abs(value);A basic queue functionality. Useful to chain your methods in order, so they can follow each other. Mainly used to state switching an animation state handling in my games.
Currently it only supports one queue chain.
Store a queue handler in your application state
typedef struct {
//...your game states
QueueState queue_state;
} AppState;
To add a new queue item
//Needed functions
void done_callback(void *ctx) {
//Called when the item is being removed from the queue
}
void start_callback(void *ctx) {
//Called every tick when it is active
}
void render_callback(const void *ctx, Canvas *const canvas) {
//Called while rendering in case you want to render something
}
//In your code somewhere
//Not needed callbacks can be set to NULL
enqueue(&(app_state->queue_state), app_state, done_callback, start_callback, render_callback, queue_run_duration)
Required to run
//Put this in a place that runs every tick
bool queue_ran = run_queue(&(app_state->queue_state), app_state);
//Put this in your render function
render_queue(&(app_state->queue_state), app_state, canvas);
Clean up at the end of your program
queue_clear(&(app_state->queue_state));
Before you can use it, you have to load the card_graphics.png file in your games assets
set_card_graphics(&I_card_graphics);
draw_card_at(pos_x, pos_y, pip, character, canvas)draw_card_at_colored(pos_x, pos_y, pip, character, inverted, canvas)draw_deck(cards, count, canvas)draw_card_back_at(pos_x, pos_y, canvas)generate_deck(deck_pointer, how_many_decks)hand_count(cards_array, how_many_cards)draw_card_animation(card, from_vector, control_vector, to_vector, current_phase, extra_time_margin, canvas)init_hand(hand_pointer, card_count)free_hand(hand_pointer)add_to_hand(hand_pointer, card)draw_card_space(pos_x, pos_y, is_highlighted, canvas)draw_hand_column(hand, pos_x, pos_y, selected_card, canvas)remove_from_deck(index_to_remove, deck_pointer)first_non_flipped_card(hand)extract_hand_region(from_hand, to_hand, start_index)lipped card index in a hand: first_non_flipped_card(hand)add_hand_region(from_hand, to_hand)Do not use it, it barely works and only used in blackjack.