Wednesday, March 1, 2023

Back to the Basics

 After more than two years, I've come back here, with the original idea still as hot as the first day. However, the approach of this entry is to create a new generic sample, so it can be checked in any system quickly.

Doing this, we can have something (similar to an SDL hello world) to test, without any Vita or SDK requirement. Besides, we can use it as a base for everything else.


First, we'll need to create our main.c file
(check https://lazyfoo.net/tutorials/SDL/01_hello_SDL/index2.php for more info)

----------------------------------------------------------

Sunday, October 11, 2020

i am not - game maker

This entry is a bit particular. I am going to explain why I decided to use game maker, and why I finally started to use it.
In addition, I will put a link to a game done with it. I hope it doesn't get too long.

First of all, there are some events called "game jam". If you have heard about hackathons or code challenges, a game jam is the same but about gamedev. A game jam consists in making a game from scratch in a short period of time.

The ludum dare (a famous game jam) was a few days ago. And I decided to enter as a mean to practice with a short goal in mind. At the begining, I wanted to use only html + canvas, however after a day and a half, the results were far from good, awful to be honest. This made me think, and I remembered I had a gamemaker version compatible with gaymaker (a tool who lets you convert the gmx project files to vpks executables on the psVita ).

To summarize the participation, I had an interesting idea, but I hadn't use gamemaker ever before. You can see that in the alpha result. When I saw the rating comments, and sent the game to a few friends; I realized that, fixing the noise and giving a more specific aesthetic to it, could be a nice minigame to have (for a prototype at least).

I spent a week after the game jam fixing errors, adding sounds, and improving the aesthetics. Within this week, I found some problems about how to handle the program to make it work 'properly' in the psVita.  When the problems where solved, and I had everything needed (specific commands and what not) I played in my console. As a result, the game runs on the web browser (html version) and psVita.

This project means that:

- I have made a game, which you can try at: https://bunkai.itch.io/i-am-not-a-murderer-v2

 - I can, somehow, make working psVita games with game maker, a.k.a. the easy way. 

- Since I want more homebrew games for the console, and I think good knowledge can help the world, I made the folder publicly available at github.  https://github.com/Bunkai9448/vita_gamemaker

- You can find the source code and the psVita vpk version at: https://github.com/Bunkai9448/vita_gamemaker/tree/main/games%20gmz-vpk

    - Now the blog can be divided in programming/learning with the psVita api, and making user homebrew (mainly games) . This is what the blog was meant since the very begining after all.

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]

Sunday, September 27, 2020

Bmax - buttonDash 01

 
Having a selection menu means you can call differents apps or modules, now we need modules to launch.
We have decided to start with a simple and easy minigame.
[The minigame will be named buttonDash, a description is comming later]

First we need to create a new btnDash.c file to work on, and add it to the CMakeLists.txt
[Reminder : This is an specific module or game inside the main app (BMAX)]

updated CMakeLists.txt


The following is to create a function in btnDash.c, we will name it btnDashGame().
This is the function we are going to launch from common.c.

With this, we update the common.c file, in the selectedApp to launch the buttonDash:
[This line goes inside selectedApp function]

if ( !strcmp(selApp,"buttonDash") ) btnDashGame ();

----

[Normally, you know what kind of modules or games you want to do before starting the project. And you do a specific menu for them. However with a launcher this part is sticked to each module. The launcher just call them, that is why we did not mention any of this before.]

We got the code ready to call our new module, it is time to decide what module is going to be.
[This part comes with idea brainstorming, but here we will go just directly to the picked idea.]

Here is a briefly explanation of what are we trying to achieve in this module:

- A minigame with highscore, and current score. Highscore will be saved in a file, for future replays.

- A game flow guided by the speed of pressing buttons correctly. A failure reset the current score.

- The button to press will be showed on screen. One button appears at a time. If no button is pressed in a specific time interval, the game will count this as a failure and, it will pass to the next button.

- An increasing difficulty based in the current score. The difficulty will have 3 stages:
   - Button image shown highlighted, 60 sec before next button appears.
   - Button will not be highlighted, 60 sec before next button appears.
   - Button will not be highlighted, 30 sec before next button appears.
[Higher difficulties with less time may be added later. Another difficuly could be show wrong button to confuse.]

- A pause menu. This screen is to be determinated.

Having the bases of the module, the next step is to draw the flowchart.
[Pseudocode could be used too, but the flowchart makes the big picture clearer. In addition, both can be done together or, done one after another.]

Warning: There are some "steps" that can be omitted, if the knowledge of the rendering were farther (which won't be done in this module).


Button dash flowchart

Tuesday, September 22, 2020

Bmax part 3.2

This entry is about making the main loop to follow the flowchart. The code will be on the main.c file, and it will (most probably) be the last one done in this file. After this, the code will be done particularly to each module, and a few lines in common.c to launch each module.
[Remember that, we are using this flowchart]

We will want to add a confirmation screen, when the user wants to exit. Right now, we have done a dummy function for that.

dummy to know if the user wants to exit


To create the flow in code, we are using a do while loop. The reasons of this are:
 - The app should, at least, show the menu at the begining.
 - We want to show this menu every time the user close any inside module (app).

To control the loop, we will need a variable which changes when the user ask to exit.
Everything else is just directly follow the flowchart.

Note: the chooseLang must be asked before the loop once, if we don't want to ask the user constantly.

main loop in main.c file

With this, it comes the first official release, go to https://homebrew-psvita.blogspot.com/2020/08/main-projects-plan-000.html and check it out.

Bmax part 3.1

In this entry we are making the functions of the main loop.

First, we declare the functions in common.h:

declare new functions in common.h

Now to code the appSelect() function, we are using the same idea of chooseLang() explained here. However, the options offered have changed. Options now:
 - help (default answer in bracket)
 - chooseLang
 - button_dash
 - exit

After doing that, we should check everything is ok, and we don't have made any typo or something. This is made by doing the main just launch it, and printing the answer (launching nothing afterwards).

main.c to check appSelect()

With this assured, we can go to implement selectedApp():

This function is basically a column of ifs with string comparison, where each option launch a function.
It will also receive two arguments, the selected app and the language to use.


selectedApp()


If everything is correct (which it is), now we have our selection menu up and running. We can do a test with:

main.c with code to check our main menu


The only thing left now is to make the loops to keep the game running, until the user wants to exit.

Monday, September 21, 2020

Bmax part 3

Up to now, we have some basic required funtions for the app. It is time to give it another essential feature, we will implement the main flowchart. To do that, we will use the one we did here.

To implement the flowchart, we need to decide a few things:

 - How are we going to get the user input?
   The user will write what he wants to do.

 - Where will the main menu go? after or before chooseLang?
   Better chooseLang right away the app init, and then main menu with option to changeLang again.

 - Which text are going to show on the selections screen?

 - Some flow decissions, that are made on the flowchart, will be explain directly on the code.
   [This should be writen in the draft with the flowchart on more official documents.]



Note 1: To make things easier, the selection menus will only have the default english ime. However we will try to make the sentences short and globally known.

Note 2: After making these selection menus, we can delete previous functions on main, and leave only these two new ones. With this, in theory, we won't have to modify main.c file again.

Note 3: To implement this, we will use one loop in each decission triangle. This will be BMAX's main loop, from there it executes other modules, or it just wait the user input.