Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a standalone start menu example
and a start screen.

not a game but an important utility. naalaa examples don't contain a standalone example for a splash screen and start menu
or screens/scenes handling.

in this file/example, I try to fix this.

about screens/scenes handling there is no game scene but I did show how to control screens with an if and boolean(the start screen).
I will create a more complex example using this code.
but it is usable as is for creating text and menu screens with a simple function and arrays.

I wanted to create a tool to do this easily. create an object array with btns and drop it into a function.
"a menu screen in one line of code" more or less.

hers the git repo with the code:

[Image: sam.gif]

the btn images are generic but can be anything for the idle and hover states. I used the blank btns as placeholders.

also, I should make tutorials for these, maybe for total noobs.

I need to test naalaa as a teaching tool for programming/ game programming. an interesting concept.
Thank you Rolen.....I haven't used NaaLaa for a while, but this will be useful when I return to it.......Kind regards.
I'm making a more complex example with scene handling.
will publish it here when I'm done.

if you have any questions about my code I'm here to help.
Nice work!

Since naalaa's not object oriented, it might be difficult to create a scene/screen system. Usually you'd prefer to keep each screen in a separate source file. One approach could be to use the old (as in existed before libraries were supported) 'run' and 'include' commands.

If you compile program_x:

wln "Hello World!"
wait keydown

, you can execute it from program_y:

run "program_x.sbe"

But it requires that you keep the sbe file that's generated when compiling program_x. However, if you modify program_y:

include "program_x.sbe"

run "program_x.sbe"

, program_y.exe will NOT need program_x.sbe when executing. 'include' includes the bytecode of a separate program (the sbe file) into the executable.

'run' terminates the currently executing program and launches a new one. But you can pass parameters between programs by filling the string array 'args' with stuff.

args[0] = "Hi"
args[1] = "There"

run "program_x.sbe"

When program_x starts, it can access the stuff in args.

Did I get off track here? Sorry Smile
I will explore that option too.

as of now, I'm using the code I created to make a game as a proof of concept (it's not a "real time" game, more of a text sim with a lot of screens).

about passing data, this can also be done using files (saving arrays/objects to files as text). it's also a very important concept. any big game needs a screen system and those screens to communicate.

Forum Jump:

Users browsing this thread: 1 Guest(s)