let gba engine auto-detect changes to scene
This commit is contained in:
parent
b6c461ad4d
commit
e457021953
|
@ -63,7 +63,7 @@ VECTOR randomDestinations[6] = {
|
|||
|
||||
void FoodScene::tick(u16 keys) {
|
||||
avatar->animateToFrame(0);
|
||||
bool bulletAdded, allowedToShoot;
|
||||
bool allowedToShoot = false;
|
||||
|
||||
if(bulletCooldown > 0) {
|
||||
bulletCooldown--;
|
||||
|
@ -78,7 +78,6 @@ void FoodScene::tick(u16 keys) {
|
|||
TextStream::instance().setText(std::string("angle pc/pd: ") + hex(avatar->getMatrix()->pc) + std::string("/") + hex(avatar->getMatrix()->pd), 4, 1);
|
||||
|
||||
/*
|
||||
|
||||
int defaultx = hex_int(GBA_SCREEN_WIDTH / 2 - 20), defaulty = hex_int(GBA_SCREEN_HEIGHT - 20);
|
||||
|
||||
auto newx = toDecimal((avatar->getMatrix()->pa * defaultx + avatar->getMatrix()->pb * defaulty) >> 8);
|
||||
|
@ -88,10 +87,8 @@ void FoodScene::tick(u16 keys) {
|
|||
*/
|
||||
if(keys & KEY_LEFT) {
|
||||
avatarRotation -= AVATAR_ROTATION_DIFF;
|
||||
TextStream::instance().clear();
|
||||
} else if(keys & KEY_RIGHT) {
|
||||
avatarRotation += AVATAR_ROTATION_DIFF;
|
||||
TextStream::instance().clear();
|
||||
}
|
||||
if((keys & KEY_A)) {
|
||||
avatar->animateToFrame(1);
|
||||
|
@ -99,7 +96,6 @@ void FoodScene::tick(u16 keys) {
|
|||
if(allowedToShoot && bullets.size() < MAX_AMOUNT_OF_BULLETS) {
|
||||
bulletCooldown = BULLET_COOLDOWN_START;
|
||||
bullets.push_back(createBullet());
|
||||
bulletAdded = true;
|
||||
|
||||
auto &b = bullets.at(bullets.size() - 1);
|
||||
b->setDestination(randomDestinations[rand() % 6]);
|
||||
|
@ -111,10 +107,6 @@ void FoodScene::tick(u16 keys) {
|
|||
for(auto &b : bullets) {
|
||||
b->tick();
|
||||
}
|
||||
|
||||
if(bulletAdded) {
|
||||
engine->updateSpritesInScene();
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<Bullet> FoodScene::createBullet() {
|
||||
|
|
|
@ -59,6 +59,7 @@ void TextStream::setText(std::string text, int row, int col) {
|
|||
// http://cs.umw.edu/~finlayson/class/spring18/cpsc305/
|
||||
void TextStream::setText(const char* text, int row, int col) {
|
||||
int index = row * TILE_WIDTH + col;
|
||||
int i = 0;
|
||||
|
||||
volatile auto ptr = &se_mem[screenBlockIndex][0];
|
||||
while (*text) {
|
||||
|
@ -66,8 +67,13 @@ void TextStream::setText(const char* text, int row, int col) {
|
|||
|
||||
index++;
|
||||
text++;
|
||||
i++;
|
||||
}
|
||||
while(i < TILE_WIDTH) {
|
||||
ptr[index] = 0;
|
||||
index++;
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TextStream& TextStream::operator<<(const int s) {
|
||||
|
|
|
@ -115,7 +115,11 @@ void GBAEngine::update() {
|
|||
}
|
||||
|
||||
u16 keys = readKeys();
|
||||
this->currentScene->tick(keys);
|
||||
currentScene->tick(keys);
|
||||
|
||||
if(currentScene->sprites().size() != spriteManager.getSpriteSize()) {
|
||||
updateSpritesInScene();
|
||||
}
|
||||
|
||||
spriteManager.render();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue