Games XUI2D

ilan

Expert
Licensed User
hi

i am not sure if this is the right place to start a thread about my thoughts about XUI2d but i hope it is and if not then erel please move it to the right place.

ok after reading so many threads and seeing really nice example made with xui2d i wanted to try the framework and see how it works. i made a lot of games until today and most are using libgdx and some also box2d (for android) and for ios am using iSpritekit. for b4j i get a very good result using simple canvas and jBox2d so this is what i use for b4j.

Anyway i started with the simple Hello World example and then also looked at the invaders and super Mario example and i really struggle to understand how it works. it is in my opinion too complicated for such simple examples like the hello world example where some donuts and rectangles fall from the sky. i would need maybe less then 80 lines for that example using spritekit, libgdx + box2d or for b4j canvas + box2d but in the xui2d example i have 7 CLASSES !! but why ??

those are just 2 objects that are created randomly so why so many classes and to be truth i still don't understand how it works. the code is to "object-oriented" for me.

i work a lot with ispritekit and i really like how simple and powerful it is so i am planning to make it possible to use the same syntex in b4a as in b4i only that i will use libgdx (or accelerated surface) and box2d for the rendering and physics calculation in the back. so the idea is using the same code as i use in my b4i apps also for b4a but only use libgdx instead. because it is very powerful and can get easily a great performance. i know it wont be easy but it is worth to start with simple object and convert them to b4a like skspritekits, skactions, skbodies etc.

it will be a very interesting project but a very powerful game making tool for ios and android!

btw i will include a very simple example using b4k and jbox2d and clone the hello world example of xui2d. in my opinion, it is much better to understand and also looks like it is shorter.

(note that it is a very simple example so much more stuff can be added and the object creating class can be and should be extended for your needs)

PS: and very old example i did using b4j and box2d (i have some mistakes in like like to angle drawing but i fixed it in a later version: https://www.b4x.com/android/forum/threads/tank-attack-jbox2d.75233/#content)
 

Attachments

  • b4j Box2d.zip
    25.7 KB · Views: 250
Last edited:

LucaMs

Expert
Licensed User
I want to comment, as I am very experienced; in fact, I have never developed 2D games (let alone 3D), I do not know libGDX or even XUI2D :D

["Then why do not you shut up?" - I do not know :D; or rather, it would be too long to explain. Also, I like to have so much source code available that maybe I can study and use and, sooner or later, I will do it]

but in the xui2d example i have 7 CLASSES !! but why ??
Many classes - source code - means more power on you hand! You know that one of the programming tips is to split / subdivide the "problem" to be solved in many small parts ("divide et impera").
Also, again without knowing libGDX, I suppose you use many of its objects, which are obviously existing classes, which you do not see and of which you do not have the source code. Maybe you use a command like: SomeLibGDXObject.Xyz not knowing that behind that simple command there is a series of cascaded classes. When I use an EditText, I could think it is a single class, and it is but:
upload_2018-8-27_6-13-30.png

all this "behind the scenes", but there are a lot of classes to create a simple EditText.

(And this one? :D)
upload_2018-8-27_6-22-32.png



Finally (although this is the main reason for the creation of XUI) you can create apps for Android and iOS with minimal changes using it, while when you use libGDX and iSpritekit your sources will certainly be much more different from each other.


Now (maybe) I can go to watch the source of XUI2D "Hello World".
["Now? You should have done it before writing these stupid things" :D]
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
i would need maybe less then 80 lines for that example using spritekit, libgdx + box2d or for b4j canvas + box2d but in the xui2d example i have 7 CLASSES !! but why ??
You are counting it wrong. The X2 classes are not your classes. Think about them as a library. You just need to add them to your project. You don't need to open the modules and you don't need to modify or add anything to these classes.

The complete code of the hello world example is less than 80 lines and most of these lines come from a template (there are about 10 lines of code added to the default template).

I could have compiled the X2 classes into a library but I think that it is better to let developers see the code when they need it (there is also a performance factor here as some of the subs in the Game class, which is your class, are called from the main loop and direct calls are the fastest calls).
 

LucaMs

Expert
Licensed User
I write here, the worst place to do it :p, one of my comments concerning Erel's sources (so you will understand that I am also able to criticize :D, although Erel already knows this - Resumable :D):

I do not understand why he, who knows perfectly the OO programming and you can see this, does not use the Regions! :eek:
 

LucaMs

Expert
Licensed User
The simplest way to create a new XUI2D project is by making a copy of one of the example folders.
despite my statement:
I have never developed 2D games (let alone 3D)
when I saw the first example, the one with the walking man, I tried to add an arrow (and shoot it, of course).
I did it in 5 minutes, having looked at the code for the first time and for a few minutes.
This demonstrates the excellent structuring of the source code (and of the excellent comments).
 

Erel

B4X founder
Staff member
Licensed User

ilan

Expert
Licensed User
You are counting it wrong. The X2 classes are not your classes. Think about them as a library.

ok i understand, so i think it would be maybe better to put them inside a lib to avoid confusion :)

Nice example. I will port it to XUI2D (based on your resources, I hope it is fine...).

sure!!!! (if i would understand how xui2d works i would do that by myself)

so a very simple question, how do i add a simple bitmap to my canvas in xui2d? how do i connect a body to it?
do i draw all bitmaps according to the bodies position or is there a simple xui2d view that holds a texture and also hold a body and i just apply forces to that body and the texture is moving automaticaly with it?

the hello world example is not clear to me. i also preffer to understand how to make simple actions and then create my classes as needed so the main activity is to empty right now.


can you create an example where everything is in the main activity and you cretate manually the bitmap view and then the body view without tiled or any class that does it automatically??

thank you erel :)
 

ilan

Expert
Licensed User
Need another 10 - 20 minutes to complete a cross platform tank:

SS-2018-08-27_08.32.33.png


really coold erel!! you have a gamer soul inside your body!! ;)
 

Erel

B4X founder
Staff member
Licensed User
ok i understand, so i think it would be maybe better to put them inside a lib to avoid confusion
XUI2D is a big framework. You need to learn how to use it. In the long run it is better for developers to have easy access to the X2 classes code. It will allow you to better understand how it works and modify it as needed.
 
Top