Intrested to boost GLBasic to a full game engine/library?

Previous topic - Next topic

Foo

Hi pals,

before I knew GLBasic, I tried some other game languages. One of the easiest and most powerfull languges was GML (Game Maker Language). Sure with GLBasic you can do nearly anything, but it's hard at the beginng, because there are no functions like move_towards_point etc.

So that, I started to create a base library, GML inspired to provide easy basic functions for game developing.
At the moment I have functions for: keyboard, mouse, sound and some movement functions.


Now I am trying to evalute if the event concept is adaptable to GLBasic - more or less -  I think so :)

With this library GLBasic will become more popular I think and easier to use.


Are you intrested in that? Would you join?
Because if we make this to a community project it would be faster usable and more stable (as with only one developer). :)

<edit>
Current status


  • 10/15/09

    • event concept implemented
    • some basic functions
    • may be first pre alpha in the following days
  • 20/15/09

    • all events present - following are triggered:

      • start step
      • step
      • end step
      • create
      • destroy
      • mouse event
      • outside room
      • no more lives
      • no more health
      • end oft path
    • function templates for a new object
    • main game template
    • first release a little bit later - got a lot of work atm
    • added mouse object (autoupdate)
    • added keyboard object (autoupdate)
</edit>

Hemlos

Welcome to GLBasic.

It should please you to know that, GLBasic has a handful of community projects, as many people show interest in making things work good!

The developer of GLBasic has begun a 2 large projects which you might be interested in. Namely, A gui system which is interactive with a user, and also a 3d entity system.

That aside I myself have a particle engine project in the works, a 2d version is mostly completed. And a 3d engine as well, this will be done soon too.

There are many large, and might i add, VERY useful libraries already built and ready to rock, with game creation as its main focus.

Take a look in this forums, in the codesnippets thread, and codesnippets group. Both areas have very useful libraries which many people have been working on for years.

Goodluck, and if you need anything, feel free to start a new topic and ask, as many people are here to help anyone with questions concerning this language.

Bing ChatGpt is pretty smart :O

Foo

There aren't much code snippets - for instance only 17 in the 2D-snippets forum - not much :(
Do you know GML? It comes with many good and usefull functions. The are many game creation projects that have adapted things from Game Maker. I have seen nothing comparable in this forum yet - may be I overlooked it...

The other thing would be, this library will be well designed, using strict code conventions for better readability and maintanance.


Hemlos

I think a game building program would be pretty cool.
But i warn you, you could spend your entire life developing it heheheh  :nana:

Let me tell you a secret about GLBasic.
The best sources of information comes in many forms:
1. Help file.
2. Samples directory, in GLBasic installation.
3. The forums here, ALL except OFFTOPIC you will find useful info. Make sure you read through all the english forums. There tutorials and FAQ, and many other catagories which are very useful. Look for threads started by Kitty_Hello, he is the dev and posts tons of useful things.
4. Last, but certainly not least, the members here in GLBasic are so helpful, they help me with my own libraries all the time.

Check out some of the members home pages, youll find GLBasic related libraries there as well.
Bing ChatGpt is pretty smart :O

Kitty Hello

Yes, you can port a GML engine to GLBasic if you wish. You will need an object list for the x,y positions of each sprite (GLBasic has a different approach - no sprites, just bitmaps and you can draw them where you want).

Foo

Quote from: Kitty Hello on 2009-Oct-12
Yes, you can port a GML engine to GLBasic if you wish. You will need an object list for the x,y positions of each sprite (GLBasic has a different approach - no sprites, just bitmaps and you can draw them where you want).

I have already done this. Creating a common object for that purpose.

But I think I'll run into a big problem - I need to add an object (Type) to an array without copying it - also by reference.
Without that I can not do things like place_free(x,y) that checks if an object is on that corresponding position.

Kitty, can you please implement this? Or is it possible to do this with inline code?

Kitty Hello

post pseudo code to show what you mean. It's all possible I'm sure.

Foo

It's like in my other thread about types:

Code (glbasic) Select

LIMITFPS 10


TYPE TBar
   text$ = ""
   x = 0
   y = 0
ENDTYPE


LOCAL a AS TBar
LOCAL b AS TBar
LOCAL c AS TBar
LOCAL d AS TBar

LOCAL list[] AS TBar
DIM list[4]

FOR i = 0 TO 3
   list[i].x = RND(1000)
   list[i].y = RND(1000)
NEXT

a.text$ = "A"
b.text$ = "B"
c.text$ = "C"
//d.text$ = "D"
//Direct try
list[3].text$ = "D"

x = 10
WHILE TRUE
   y = 10
  // Instance manipulated directly
  a.x = RND(320)
   FOR i = 0 TO 3
      PRINT "Text: " + list[i].text$ + " x: " + list[i].x + " y: " + list[i].y, x, y
      INC y, 10
   NEXT
   // Now this check could fail, because a has another x than list[0].x
   IF(TBar_PositionFree(list[], 10, 10) = FALSE)
       //SOMETHING HAS TO HAPPEN NOW... ;)
    ENDIF

   SHOWSCREEN
   KEYWAIT
WEND

FUNCTION TBar_PositionFree: _instanceList[], x, y
FOREACH e IN _instanceList
IF(e.x = x) AND (e.y = y)
RETURN 1
ENDIF
NEXT
RETURN 0
ENDFUNCTION



Problem is here as follows:

Sometimes I manipulate the instances directly, like a.name$ = "A" and sometimes I have to manipulate all instances in an array/list. For example when I check if any instance, in a list, is on position x, y.
Pitfall here: if a function manipulates instance x and y position, the item in the list is not updated - so that, the check fails.

If a type instance pointer (or better - the reference) is given, when putting it into the list, everything would be okay. When it's copied, there are two different instances (like cloning an object), thats really bad.

Do you know what I mean? If it's unclear, I can provide a more detailed example.


(PS. above function code is untested, just wrote it down)

Moru

I'm a bit tired still but if you want to call a function with a list as parameter, change the values inside the function and then access the new values outside the function, that code is perfectly fine since all functioncalls with a list (array) is by reference which means that it's just a pointer to the data you are passing to the function, not a copy of the whole array.

Kitty Hello

Right. Passing arrays and types to a function is always done by reference.
For strings and numbers you can use the BYREF argument to force this.

Foo

No thats not the point. The problem isn't the function the problem is the array.

Hope this clears it a bit better - code is full runnable:

Code (glbasic) Select
TYPE TBar
x = 0
y = 0
ENDTYPE

LOCAL a AS TBar
LOCAL b AS TBar
LOCAL list[] AS TBar
DIM list[2]

// Direct manipulating - must be possible
a.x = 10
a.y = RND(1000)

b.x = RND(1000)
b.y = RND(1000)

// This is the problem a, b are copied when putting it into the
list[0] = a
list[1] = b


// HERE a.x WAS 10 AND NOW BECOMES 5!
a.x = 5
// SO IF THE INSTANCE a IS NOT COPIED INTO THE ARRAY
IF(TBar_CheckXEquals5(list[]))
//THIS WILL NEVER HAPPEN! Coz a was copied when putted into the list @see line 19
PRINT "Yipiee x is now 5", 10, 10
ELSE
//Please say not, you can do list[0].x = 5 this is not what I need
PRINT "BAD!!! Variables are copied. No chance to set x to 5!", 10, 10
ENDIF
SHOWSCREEN
KEYWAIT


// This function does some test, with all elements in the list
FUNCTION TBar_CheckXEquals5: _instanceList[] AS TBar
LOCAL e AS TBar
FOREACH e IN _instanceList[]
IF(e.x = 5) THEN RETURN 1
NEXT
RETURN 0
ENDFUNCTION




Moru

Ok, now I understand what you are trying to do. But I think you have this confused with c++ :-) You are doing a copy operation. "a = b" is a copy. You want to pass a reference of a = *b or something like that in c? I don't know how to do that without using your own list and passing your own index number as a reference.

Hypothetical code only takes you that far, I can't realy help more if I don't know more about your program.

Kitty Hello

Code (glbasic) Select


ALIAS ptr_to_a AS list[0]
ptr_to_a.x = 5


Do it this way.

Foo

Sorry,

its not fully working with the ALIAS statement:

Code (glbasic) Select

// --------------------------------- //
// Project: testalias
// Start: Thursday, October 15, 2009
// IDE Version: 7.144


// SETCURRENTDIR("Media") // seperate media and binaries?

TYPE TObject
object_type$ = ""
x = 0
y = 0
ENDTYPE


LOCAL all[] AS TObject
LOCAL typeAList[] AS TObject
LOCAL typeBList[] AS TObject

LOCAL a AS TObject
LOCAL a2 AS TObject

LOCAL b AS TObject
LOCAL b2 AS TObject

a.x = 10
a.y = 10
a.object_type$ = "A"

a2.x = 10
a2.y = 10
a2.object_type$ = "A"

b.x = 10
b.y = 10
b.object_type$ = "B"

b2.x = 10
b2.y = 10
b2.object_type$ = "B"

DIM all[4]
DIM typeAList[2]
DIM typeBList[2]

all[0] = a
all[1] = a2
all[2] = b
all[3] = b2

ALIAS Aa  AS all[0]
ALIAS Aa2 AS all[1]
ALIAS Ab  AS all[2]
ALIAS Ab2 AS all[3]

typeAList[0] = Aa
typeAList[1] = Aa2

typeBList[0] = Ab
typeBList[1] = Ab2


FOREACH e IN typeAList[]
INC e.x, 1
NEXT

FOREACH e IN typeBList[]
INC e.y, 2
NEXT
y = 10
FOREACH e IN all[]
PRINT e.object_type$ + " - X: " + e.x + " Y: " + e.y, 10, y
DEBUG e.object_type$ + " - X: " + e.x + " Y: " + e.y + "\n"
INC y, 10
NEXT
SHOWSCREEN
KEYWAIT


Result:
Quote
A - X: 10 Y: 10
A - X: 10 Y: 10
B - X: 10 Y: 10
B - X: 10 Y: 10

Expected:
Quote
A - X: 11 Y: 10
A - X: 11 Y: 10
B - X: 10 Y: 12
B - X: 10 Y: 12

MrTAToad

I have noted that arrays aren't always passed by reference, but instead a copy is made.  This also applies when returning a structure as well...

[edit] Wrong. Array _always_ byref