Zal0 / ZGB

Game Boy / Color engine with lots of features

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Glitched animation

afska opened this issue · comments

I'm not sure if this's a bug but... I'm trying to add a sprite with a simple 4 frames 32x32 animation.

I added this to ZGBMain.h:

_SPRITE_DMG(SPRITE_ENEMY, enemy, 3, FRAME_32x32, 4)\

I have an exported enemy.b3.c file under res/src.

The enemy code is:

#pragma bank 2
#include "main.h"
UINT8 bank_SPRITE_ENEMY = 2;

#include "SpriteManager.h"

const UINT8 anim_enemy_idle[] = {0, 1, 2, 3};

void Start_SPRITE_ENEMY() {
	SetSpriteAnim(THIS, anim_enemy_idle, 15);
}

void Update_SPRITE_ENEMY() {

}

void Destroy_SPRITE_ENEMY() {
}

The result is:
https://www.youtube.com/watch?v=NDc7awTalys

I would appreciate any advice!

commented

Animations are declared as arrays of UINT8, the first value is the number of frames
You should write anim_enemy_idle like this

const UINT8 anim_enemy_idle[] = {4, 0,1, 2, 3};

@Zal0 Thank you, and sorry for the n00b question!

I was wondering how the hell ZGB knew the array size 😅

commented

No problem 👍