Clang format card.c/h (#256)
This commit is contained in:
@@ -20,6 +20,7 @@ jobs:
|
|||||||
run: >
|
run: >
|
||||||
clang-format --dry-run -Werror
|
clang-format --dry-run -Werror
|
||||||
include/bitset.h source/bitset.c
|
include/bitset.h source/bitset.c
|
||||||
|
include/card.h source/card.c
|
||||||
include/hand_analysis.h source/hand_analysis.c
|
include/hand_analysis.h source/hand_analysis.c
|
||||||
include/list.h source/list.c
|
include/list.h source/list.c
|
||||||
include/sprite.h source/sprite.c
|
include/sprite.h source/sprite.c
|
||||||
|
|||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
#ifndef CARD_H
|
#ifndef CARD_H
|
||||||
#define CARD_H
|
#define CARD_H
|
||||||
|
|
||||||
#include <tonc.h>
|
|
||||||
#include <maxmod.h>
|
|
||||||
|
|
||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
|
|
||||||
|
#include <maxmod.h>
|
||||||
|
#include <tonc.h>
|
||||||
|
|
||||||
#define MAX_CARDS (NUM_SUITS * NUM_RANKS)
|
#define MAX_CARDS (NUM_SUITS * NUM_RANKS)
|
||||||
#define MAX_CARDS_ON_SCREEN 16
|
#define MAX_CARDS_ON_SCREEN 16
|
||||||
|
|
||||||
|
|||||||
+15
-10
@@ -1,18 +1,17 @@
|
|||||||
#include "card.h"
|
#include "card.h"
|
||||||
|
|
||||||
#include <maxmod.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "deck_gfx.h"
|
#include "deck_gfx.h"
|
||||||
#include "graphic_utils.h"
|
#include "graphic_utils.h"
|
||||||
|
|
||||||
|
#include <maxmod.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
// Audio
|
// Audio
|
||||||
|
#include "pool.h"
|
||||||
#include "soundbank.h"
|
#include "soundbank.h"
|
||||||
|
|
||||||
#include "pool.h"
|
|
||||||
|
|
||||||
// Card sprites lookup table. First index is the suit, second index is the rank. The value is the tile index.
|
// Card sprites lookup table. First index is the suit, second index is the rank. The value is the tile index.
|
||||||
const static u16 card_sprite_lut[NUM_SUITS][NUM_RANKS] = {
|
const static u16 _card_sprite_lut[NUM_SUITS][NUM_RANKS] = {
|
||||||
{0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192},
|
{0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192},
|
||||||
{208, 224, 240, 256, 272, 288, 304, 320, 336, 352, 368, 384, 400},
|
{208, 224, 240, 256, 272, 288, 304, 320, 336, 352, 368, 384, 400},
|
||||||
{416, 432, 448, 464, 480, 496, 512, 528, 544, 560, 576, 592, 608},
|
{416, 432, 448, 464, 480, 496, 512, 528, 544, 560, 576, 592, 608},
|
||||||
@@ -72,7 +71,8 @@ CardObject *card_object_new(Card *card)
|
|||||||
|
|
||||||
void card_object_destroy(CardObject** card_object)
|
void card_object_destroy(CardObject** card_object)
|
||||||
{
|
{
|
||||||
if (*card_object == NULL) return;
|
if (*card_object == NULL)
|
||||||
|
return;
|
||||||
sprite_object_destroy(&((*card_object)->sprite_object));
|
sprite_object_destroy(&((*card_object)->sprite_object));
|
||||||
POOL_FREE(CardObject, *card_object);
|
POOL_FREE(CardObject, *card_object);
|
||||||
*card_object = NULL;
|
*card_object = NULL;
|
||||||
@@ -80,15 +80,20 @@ void card_object_destroy(CardObject **card_object)
|
|||||||
|
|
||||||
void card_object_update(CardObject* card_object)
|
void card_object_update(CardObject* card_object)
|
||||||
{
|
{
|
||||||
if (card_object == NULL) return;
|
if (card_object == NULL)
|
||||||
|
return;
|
||||||
sprite_object_update(card_object->sprite_object);
|
sprite_object_update(card_object->sprite_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
void card_object_set_sprite(CardObject* card_object, int layer)
|
void card_object_set_sprite(CardObject* card_object, int layer)
|
||||||
{
|
{
|
||||||
int tile_index = CARD_TID + (layer * CARD_SPRITE_OFFSET);
|
int tile_index = CARD_TID + (layer * CARD_SPRITE_OFFSET);
|
||||||
memcpy32(&tile_mem[4][tile_index], &deck_gfxTiles[card_sprite_lut[card_object->card->suit][card_object->card->rank] * TILE_SIZE], TILE_SIZE * CARD_SPRITE_OFFSET);
|
memcpy32(&tile_mem[4][tile_index],
|
||||||
sprite_object_set_sprite(card_object->sprite_object, sprite_new(ATTR0_SQUARE | ATTR0_4BPP | ATTR0_AFF, ATTR1_SIZE_32, tile_index, 0, layer + CARD_STARTING_LAYER));
|
&deck_gfxTiles[_card_sprite_lut[card_object->card->suit][card_object->card->rank] * TILE_SIZE],
|
||||||
|
TILE_SIZE * CARD_SPRITE_OFFSET);
|
||||||
|
Sprite* sprite =
|
||||||
|
sprite_new(ATTR0_SQUARE | ATTR0_4BPP | ATTR0_AFF, ATTR1_SIZE_32, tile_index, 0, layer + CARD_STARTING_LAYER);
|
||||||
|
sprite_object_set_sprite(card_object->sprite_object, sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
void card_object_shake(CardObject* card_object, mm_word sound_id)
|
void card_object_shake(CardObject* card_object, mm_word sound_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user