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>
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.
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.
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.
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).
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?
post pseudo code to show what you mean. It's all possible I'm sure.
It's like in my other thread about types:
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)
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.
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.
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:
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
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.
ALIAS ptr_to_a AS list[0]
ptr_to_a.x = 5
Do it this way.
Sorry,
its not fully working with the ALIAS statement:
// --------------------------------- //
// 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
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
Yes, I now. But if the ALIAS works as a pointer, there would be no problem.
And to prevent performance issues and other things I need a pointer.
Imagine all[] contains all current game objects - lets say 10.000
But some operations are made only with the object_type = "b"
If there are 6000 object_type = "a" objects and 4000 object_type = "b" in the list. I have to do 6000 useless loops and if statements.
From my experience with arays, it would be best to only use 1 dimensional arrays with 1 type of object to be processed.
Split it into 2 arrays.
I used dozens of arrays together to accomplish getting rid of redundant memory slots.
Is this way not efficient to do?
typeAList[0] = Aa
typeAList[1] = Aa2
typeBList[0] = Ab
typeBList[1] = Ab2
No, sorry - here you're doing a copy assignment.
You want to store a list of pointers to objects in another list. That's not possible. Redesign your application, I bet there's another way t do it instead.
QuoteSplit it into 2 arrays.
As you can see in my example thats not possible.
But we are running now in a situation, what we call in Germany: "Verzetteln" :)
@Kitty
Is it possible to implement that pointer thing?
I am a software developer mainly web applications and Java desktop apps - so that I know that referencing types (objects) are the right thing.
If you say: "Sorry, thats not possible - okay, then I must find an another solution for that problem."
But if you say: "Okay, thats possible, but requires... or it can't be done until I...." Alright, then I know don't have to touch my design, or something like that.
For instance, if I can work with pointers. Nearly every design pattern is possible. For example: Observer, Proxy, Plugin...
Just to back up the original post, there is no problem making a Game Maker type of product. I have two different games that include a custom scripting language. The games can be "modded" or new standalone games can be made to share with others.
There's 2 possibilities for your problem.
a) (nice one) keep a list of indices for the objects you need in A
LOCAL indA%[]
DIMDATA indA%[], 5,7,2234
FOREACH id% IN indA%[]
ALIAS obj AS gObjects[id%]
obj...
NEXT
b) (bad kitty, bad) Use INLINE to get your pointers.
INLINE
DGArray<MyType*> ptrs;
DIMPUSH(ptrs, &obj(123) );
for(int i=0; i<LEN(ptrs); ++i)
{
ptrs(i) -> DoSomething...
}
Really - go the first route.
Quote from: Kuron on 2009-Oct-15
Just to back up the original post, there is no problem making a Game Maker type of product. I have two different games that include a custom scripting language. The games can be "modded" or new standalone games can be made to share with others.
Thats nice :) Interested to share your thoughts and experience? In a few days I'll be releasing (so I hope) a first alpha version of my GML inspiered thing, hmm I think you can call it something like a GLBasic framework. I was able to implement the object concept including the event system from GM.
At the moment you can use the following events:
- draw
- collision (half finished)
- step
- begin step
- end step
- keyboard
- mouse
At the object behavior site its possible to use the following attributes with functions:
object_id, x, y, direction, speed, move_to_point (isMoving),
There are some movement functions like move_to_point and move (by direction and speed) too.
Plus a few functions for draw and sound.
@Hello Kitty
Thanks for the code - may be I can do what I need with that :)
What language did you choose to create the GLBasic IDE?
I was thinking about the GUI possibilities of my idea...
I use C++ / MFC for the GUI, because that's what I use at work and know most about.
Thanks for the info - first I thought it was build with Delphi.... =D
So its C++ what you use for the IDE too. BTW: Do you think its possible to use regular expressions easily with inline?
QuoteInterested to share your thoughts and experience?
I am not well-liked around here, so I rarely post anymore ;)
the IDE is MS Visual Studio, the best IDE ever (if you disagree, you propably have not used it before). But it's not very cheap.
We're working on regexp, but there seems to be a problem with the output, still.
Visual Studio (and extras) was available for free at one point from Microsoft - I don't know if it still is. I used the Enterprise Edition many, many moons ago and thought it was pretty good, although my experience of devving in C++ was pretty limited at the time (even less now!).
Hello,
the project process continues :)
Added the full event concept - a lot of them are triggerd @see first post.