Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
picking sticks in naalaa and a few questions
#1
Photo 
I ported my hello world for game dev to naalaa:

https://github.com/yoel123/naalaa-picking-sticks

[Image: picking.gif]

a simple game to implement. I use it to get up and running with different engines (the gif is of an android port).

I really like naalaa, it has a lot of libraries and tools I can't implement myself like raycasting and pathfinding. the sprite "grid" is one of the best I ever used, I also liked the tilemap and collision detection.

the only problem is that I can't do without oop: class and inheritance. my game framework is based on this.

I somehow managed in blitz 3d with their objects, but naalaas objects can only hold variables. not images or functions. 

how would you suggest I do this? I didn't code games with procedural programming in almost 10 years.
I learned game programming properly with flashpunk an as3 game engine. which is heavily oop based.
today I use mostly java or lua (corona sdk) even javascript has a prototype based oop.

what do you think what should I do?

my next goal is to make a naalaa cheatsheet and port my clicking stars game. for future newcomers.

I also consider using naalaa as a teaching tool for total beginners who want to get into game dev.
it has a very low entry barrier and a lot of tools.
Reply
#2
(01-24-2019, 01:25 PM)rolen Wrote: I ported my hello word for game dev to naalaa:

https://github.com/yoel123/naalaa-picking-sticks

[Image: picking.gif]

a simple game to implement. I use it to get up and running with different engines (the gif is of an android port).

I really like naalaa, it has a lot of libraries and tools I can't implement myself like raycasting and pathfinding. the sprite "grid" is one of the best I ever used, I also liked the tilemap and collision detection.

the only problem is that I can't do without oop: class and inheritance. my game framework is based on this.

I somehow managed in blitz 3d with their objects, but naalaas objects can only hold variables. not images or functions. 

how would you suggest I do this? I didn't code games with procedural programming in almost 10 years.
I learned game programming properly with flashpunk an as3 game engine. which is heavily oop based.
today I use mostly java or lua (corona sdk) even javascript has a prototype based oop.

what do you think what should I do?

my next goal is to make a naalaa cheatsheet and port my clicking stars game. for future newcomers.

I also consider using naalaa as a teaching tool for total beginners who want to get into game dev.
it has a very low entry barrier and a lot of tools.


Welcome to the forum rolen, i just update your code to work under Linux also, here are the modifications.


Code:
import "Keycodes.lib"

set window (screenw()-300 )/2, (screenh() - 400)/2, 520, 540



set redraw off

rem ---------player data (w = width, h = height)
p?
p.x = 10
p.y = 10
p.w = 20
  p.h = 20
p.speed = 3;
p.frame = 2

rem ----------stick data (stick x and y is random)
s?
s.x = rnd(300)
s.y = rnd(300)
s.w = 20
s.h = 20

rem --------- player points
points = 0
rank$ ="none"


rem ---------asstes vars
stickImg = 1
player = 2

rem ------- load assets---------
load image stickImg , "res/stick.png"

load image player , "res/stick_picker.png"
set image grid player, 4, 5

rem ---------game loop
do
    set color 0, 0, 0
    cls

rem ---------------start game loop--------------

    rem --------------------- update
    m = keyboardControl(p)
    rem if player toch stick move stick to a random pos and add1 to points
    if collide(p,s)
        s.x = rnd(300)
        s.y = rnd(300)
        points = points+1
    endif
    

    rem -------------------- render
    set color 255, 255, 255
    draw image stickImg  , s.x, s.y
    draw image player , p.x, p.y,p.frame
    rem draw points to screen
    set caret 10, 10
    write "points: ",points
    rem print rank
    rank = rankHandale(points)
    set caret 150, 10
    write "rank: ",rank

rem ---------------end game loop----------------------
    redraw
    wait 20
until keydown(" ") or not running()


function keyboardControl(&p?)


        rem up
      if keydown(VK_UP)
            p.y = p.y - p.speed
            p.frame = 0

        endif
        rem down
        if keydown(VK_DOWN)
            p.y = p.y + p.speed
            p.frame = 2
        endif
        rem left
        if keydown(VK_LEFT)
            p.x = p.x - p.speed
            p.frame = 3
      endif
        rem right
        if keydown(VK_RIGHT)
            p.x = p.x + p.speed
            p.frame = 1
      endif

    return 0
endfunc  
rem end kyboard control

rem hit test function
function collide(a?, b?)
    if a.x + a.w < b.x then return false
    if a.x > b.x + b.w then return false
    if a.y + a.h < b.y then return false
    if a.y > b.y + b.h then return false
    return true
endfunc
rem end collide

rem rank handler function (changes rank text )
function rankHandale$(points)
    rank$="none"
    if points > 10 then rank = "stick picker"
    if points > 20 then rank = "pro stick picker"
    if points > 25 then rank = "master stick picker"
    if points > 30 then rank = "no life"
    if points > 35 then rank = "you shod stop you know"
    if points > 40 then rank = "this game never ends"
    if points > 50 then rank = "good job you win"
    if points > 60 then rank = "you can stop now"

    return rank
endfunc
rem end rankHandale


The changes that i made was, i import "Keycodes.lib" so i can use the const VK_UP etc keys, and in the function collide(a?, b?), i change it from passing the value by reference to passing by value, this because you do not need to change nothing in that function, only access the values in it.

Hope you don not mind it.

Quote:what do you think what should I do?

I don't get the question, could you elaborate more?

Thanks
Reply
#3
ok, I will update the code in a minute. thanks.

"I don't get the question, could you elaborate more?"

what I mean is about oop (object oriented programming) naalaa doesn't seem to have this. you can't even attach a function or image to an object.

I'm not used to doing things without oop especially in game programming.

without oop, I can't port my framework to naalaa. which will make it harder to develop more complex games.
Reply
#4
Well in Naalaa only supports simple objects if I'm not mistaken, like you use in the pick the stick, It doesn´t support oop like java c# c++ or other ones that use classes and inheritance etc.
Reply
#5
I got that. what im asking is what can I do about it?

is there a way to simulate class and inheritance?

as I mentioned in blitz3d I managed to simulate a kind of oop. and ported my framework to it.
Reply
#6
No, only simple objects, the only way is to do it is from the ground up.
Reply
#7
I have done some research with old tomes from the dark age of technology where oop was none existent.

there I found the ancient scrolls of doom written by the mighty Carmack (who allows us to also call him John).

within them, it is said that all class are structs with functions tied together by the "this".

for example:

monster.move(speed);

can become:
move(monster,speed);

and if tho cannot use structs then arrays can be used instead:

monstersx[100]
monstersy[100]
i=2
move(monsterImg,monstersx[i],monstery[i],speed)

thos object oriented programming is possible with less abstraction. even when unimplemented in a language.
our luck is that naalaa has structs as objects.

praise the omnissiah
praise the machine god
Reply
#8
Well, that's the old way and the NaaLaa has the simple objects that help alot, if you need any help just ask.
Reply
#9
sure thanks I appreciate this. I'm sure I will run into a wall very soon.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)