I want to use one Image for spritesheets, loading them when the section of the program changes

General

NeoTechni

8 months ago

#include <Gamebuino-Meta.h>

Image Sprites;
Image Font("DrMario/font.bmp");
uint8_t PrevMode = -1;

void setup() {
    gb.begin();
    loadmode(0);
}
void loop() {
    while(!gb.update());
    gb.display.clear();
    //gb.display.print("hello, world");
    switch (PrevMode){
        case 0: //menu
            
            break;
        case 1: //in-game

            break;
    }
}

void loadmode(uint8_t Mode){
    if(PrevMode != Mode){
        if(PrevMode == -1){
            
        }
        PrevMode = Mode;
        switch (Mode){
            case 0: //menu
                Image Sprites("DrMario/menu.bmp");
                break;
            case 1: //in-game
                Image Sprites("DrMario/ingame.png");
                break;
        }
    }
}

I'm having problems. 

1) I don't trust that this is the correct way to re-use an Image variable. I'm worried it's redeclaring Sprites as a local variable

2) It doesn't like my switch case. I get "jump to case label [-fpermissive]" on "case 1: //in-game" in loadmode.

Sorunome

NEW 8 months ago

1) I don't trust that this is the correct way to re-use an Image variable. I'm worried it's redeclaring Sprites as a local variable

with myImage.init() and put in it the parameters you would use in the normal constructor


And as to sprite sheets....did you see https://gamebuino.com/creations/images the section "Sprite sheet & Tilemapper" ?


2) It doesn't like my switch case. I get "jump to case label [-fpermissive]" on "case 1: //in-game" in loadmode.

I am not entirely sure but you are trying to use locally defined (as in, inside the switch statement) variables outside



Also, please use code tags instead of quote for code



And then i also glanced over this:

                Image Sprites("DrMario/ingame.png");

The library doesn't support PNGs

NeoTechni

NEW 8 months ago

I switched to .init.

The documentation claimed it supports PNG, specifically because anything less than 50% visible would count as an invisible pixel. Only PNG supports transparency like that 

The other issue seems to have gone away. Thank you, I'll keep the code tag in mind too

Sorunome

8 months ago

The documentation claimed it supports PNG, specifically because anything less than 50% visible would count as an invisible pixel. Only PNG supports transparency like that

Where is that? Must have been a mistake on my end. And BMP does support transparency, 32-bit depth BMPs ;)

Sorunome

NEW 8 months ago

NeoTechni NeoTechni

The documentation claimed it supports PNG, specifically because anything less than 50% visible would count as an invisible pixel. Only PNG supports transparency like that

Where is that? Must have been a mistake on my end. And BMP does support transparency, 32-bit depth BMPs ;)

You must be logged in in order to post a message on the forum

Log in