Good Morning,
I've been following this forum for a long time because I like the naalaa engine, although I've always had a doubt about it and hoped that a new version of the compiler would rectify the problem that's happening to me.
Simply when I run any example, I notice that from time to time there are frame jumps and it is visually appreciated. I don't know if it is because a powerful computer is required to solve such a problem or there is a command that solves this.
I hope that naalaa continues to improve day by day.
I found some nice assets for a Candy Crush-style game on opengameart and implemented the basics. Several games of this kind has been posted before, but I believe non of them uses the swap-pieces-controls?
I am going to get in early, just in case I may forget, to wish everyone a safe and happy Xmas and New Year... (insert celebratory sounds and emoji's here...) All the best!!!
Posted by: Marcus - 11-19-2022, 07:01 AM - Forum: N7
- Replies (5)
NED, Tilemap Editor and NGUI Theme Editor were written in n7 using the ngui library. I just added the "widgets" and "containers" that I needed to this library as I created the editors. It may be hard to use if you've never worked with other gui libraries like IUP, Swing or WPF. But the principle is that you use containers to arrange widgets in different ways, you never position anything using exact coordinates. The library responds to window size changes by rearranging and resizing the containers and widgets. You can find the n7 source code of ngui in the N7/lib folder.
Here's a first example that creates some menus and labels.
Code:
' NGUI - Menus
' ------------
#win32
' This library is really large, so including it increases the compile time quite a bit.
include "ngui.n7"
' These will be explained later.
visible fruitLabel, gameLabel
' Create a resizable window.
set window "NGUI - Menus", 640, 480, false, 0
set redraw off
' Ngui uses containers to arrange widgets in different ways. The containers are widgets too.
' Every window needs a root widget, and it's usually a container. Here I create a vbox (vertical
' box), that aranges its children vertically. This will be the root widget of the window.
windowRoot = VBox(SIZE_EXPAND, SIZE_EXPAND)
' A menubar contains one or more menus. A menu has a title, like "File", and a bunch of children,
' like "Open", "Save" and "Save as".
' Create a menubar and add it to windowRoot.
menuBar = MenuBar()
windowRoot.Add(menuBar)
' Create a menu. The parameter is a function that will be called every time the user selects
' something in the menu. The function FruitMenuCallback is defined later in this program.
fruitMenu = Menu(FruitMenuCallback)
' Add some items to fruitMenu. The second parameter can be used to display something to the right
' of a menu item, usually a keyboard shortcut such as "Ctrl+N", but let's just skip that.
fruitMenu.Add("Banana", unset)
fruitMenu.Add("Apple", unset)
fruitMenu.Add("Pear", unset)
' Add fruitMenu to menuBar, the first parameter is the menu title.
menuBar.Add("Fruits", fruitMenu)
' Create another menu with another callback function.
gameMenu = Menu(GameMenuCallback)
gameMenu.Add("Crap's Adventure", unset)
gameMenu.Add("Bulb Boy", unset)
gameMenu.Add("Farmer Man", unset)
gameMenu.Add("Robowack", unset)
menuBar.Add("Games", gameMenu)
' Create another vbox and add it to the root.
vbox = VBox(SIZE_EXPAND, SIZE_EXPAND)
windowRoot.Add(vbox)
' Make this vbox center its children.
vbox.SetHalign(ALIGN_CENTER)
vbox.SetValign(ALIGN_CENTER)
' Add some text widgets to the vbox
vbox.Add(Header("Menus are super fun!", SIZE_AUTO, SIZE_AUTO))
vbox.Add(Label("Select stuff in the menus and things will happen", SIZE_AUTO, SIZE_AUTO))
' Add a filler, just empty space, of height 16.
vbox.Add(Filler(SIZE_AUTO, 16))
' Add two more labels, that will be modified from the menu callback functions.
fruitLabel = Label("No fruit selected", SIZE_AUTO, SIZE_AUTO)
gameLabel = Label("No game selected", SIZE_AUTO, SIZE_AUTO)
vbox.Add(fruitLabel)
vbox.Add(gameLabel)
' Enter main loop with windowRoot as root widget. From here on all action goes through the callback
' functions.
EnterMainLoop(windowRoot)
' Callback function for the fruit menu.
function FruitMenuCallback(menu, index)
select index
case 0 fruitLabel.SetText("I know how to spell banananananana but not when to quit")
case 1 fruitLabel.SetText("APPLE!!!")
case 2 fruitLabel.SetText("I don't remember what the third fruit was, sorry ...")
default fruitLabel.SetText("Undefined fruit encountered")
endsel
endfunc
' Callback function for the game menu.
function GameMenuCallback(menu, index)
select index
case 0, 1 gameLabel.SetText("You selected a platform game")
case 2 gameLabel.SetText("You selected a pacman clone")
case 3 gameLabel.SetText("You selected a first person shooter")
endsel
endfunc
Does anyone have instructions on creating a simple database application using Naalaa? As I have to record my blood sugars on a daily basis, I figured that rather than using N7 for just games, why not try to create a practical application?
LibreOffice has a builtin DB application... but where is the fun in that? lol
Hello,
Some time ago I programmed a videogame in another language but not even the Pope in Rome knows it XD. I can provide code, I would pass it on to Naalaa, but I still haven't studied this language in depth.
The game is very simple, you just have to press the z key. When you get ten hits in a row, you throw a mega bomb that completely destroys the building. If you miss, be careful, increase the speed! until after a clock time... If you pass several levels, you enter the records panel and it looks like it's celebrated XD!!
Be careful if you fail, the speed will increase and the plane will end up shot down!!
A fan of the mythical amstrad computer
' Bubble universe
' ---------------
' Paul Dunn posted this code but for SpecBAS in a facebook group. It looked so cool that I had to
' rewrite it in n7.
constant TAU = 6.283185307179586
set window "Bubble universe", 512, 512
set redraw off
n = 200; r = TAU/235
x = 0; y = 0;
v = 0; t = 0;
hw = width(primary)/2; hh = height(primary)/2
while not keydown(KEY_ESCAPE)
set color 0, 0, 0
cls
for i = 0 to n for j = 0 to n
u = sin(i + v) + sin(r*i + x)
v = cos(i + v) + cos(r*i + x)
x = u + t
set color i, j, 99
set pixel hw + u*hw*0.4, hh + v*hh*0.4
next
t = t + 0.025
set caret hw, 4
set color 255, 255, 255
center "Press esc to exit ..."