Tuesday, September 29, 2020

Bmax - buttonDash 02

As an easy way to show the user what button has to press in each moment, we are going to use the SDL and the screen.c file we created before (don't worry if you don't remember, we are going to practically explain it again).

[Mind you, this entry is made after we adapted screen.c to load a bmp file. That means we can load the pictures in the cmake lists before the code explained here. Nevertheless, we have to make that modular]

Adding pictures to the CMakeLists.txt


With the previous part clear, we can start our road to load the bmp file in the psVita screen.

Note: images will be in BMP because the PNGs require another package to SDL (SDL_image). Although this package works equaly to the one we are using, there's not enough of it defined for the psVita and it won't run without a lot of extra effort.

The First thing to do is define the functions in the headers file (common.h). We are going to need four:
 - One for initializing the library. This also creates the window where the image is load.
 - One for loading the image file.
 - One for cleaning and closing the SDL
 - One (dummy) that calls the other three and print a image on screen (this will be our goodBye img for the app).

Defining the new functions in common.c

With those defined, we can proceed to make the code for them (in screen.c):

initialise SDL

Load bmp image

Clean memory and close SDL + goodBye dummy

Now it's time to focus on the buttonDash code. A good start point is to print the rules (image) on screen using SDL.

Function to load rules image in buttonDash.c


Warning: When all of this is done, it loads the rules image on screen, but it fails to load a second image (specifically fails at creating a new window). Solving this is currently our next step. [It has to be something with the sdl and the memory management]

No comments:

Post a Comment