### Author Topic: 2D - "Entity System"  (Read 2282 times)

#### backslider

• Community Developer
• Prof. Inline
• Posts: 892
##### 2D - "Entity System"
« on: 2012-Jun-15 »
Hi guys,

would you be interested in a "2D Entity System" where you can easily create an entity like in the 3D Entity System and then use powerful functions to move / rotate them?

An example code with 10 boxes moving relative to there parents would look like this:
Code: (glbasic) [Select]
`// --------------------------------- //// Project: 2DEntity// Start: Friday, June 15, 2012// IDE Version: 10.202SYSTEMPOINTER TRUE //enable the system pointer//grab a test spriteLOCAL spr% = GENSPRITE()DRAWRECT 0,0,10,10,RGB(255,0,0)GRABSPRITE spr,0,0,10,10//---INIT ENTITY STUFF---LOCAL es2D AS T2DEntitySystem //create a new entity systemLOCAL boxes[] //entity array//create 10 entities in a lineFOR i%=0 TO 9 LOCAL box% = es2D.CreateEntity(i * 30, 0, 0) es2D.SetTexture(box, spr) IF i > 0 THEN es2D.SetParent(i, i-1) //the entity before is now the parent of this entity DIMPUSH boxes[], boxNEXTLOCAL angle# = .0//---MAIN LOOP---WHILE TRUE LOCAL mx,my,b1,b2 MOUSESTATE mx,my,b1,b2         //move the angle with the mouse buttons ;) angle = 0 IF b1 THEN angle = 1 IF b2 THEN angle = -1 FOR i%=0 TO 9 es2D.Rotate(boxes[i], angle*i/10) NEXT es2D.SetPosition(boxes[0],mx-5,my-5) es2D.DrawSystem() //draw the whole system with only one command :) SHOWSCREENWEND`
The result would look like the demo in the attachments :

#### kaotiklabs

• Dr. Type
• Posts: 313
• Spain is diferent
##### Re: 2D - "Entity System"
« Reply #1 on: 2012-Jun-15 »
Yeah, it would be very good for even manage game menus with transitions easily.

Is a great idea.
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

#### backslider

• Community Developer
• Prof. Inline
• Posts: 892
##### Re: 2D - "Entity System"
« Reply #2 on: 2012-Jun-15 »
Maybe monday I will upload a first version of the system!

#### mentalthink

• Prof. Inline
• Posts: 3375
• Integrated Brain
##### Re: 2D - "Entity System"
« Reply #3 on: 2012-Jun-15 »
Hi backslider sounds very interesting!!! a lot of work, but I think can be very usefull if itÂ´s easy to use...

Thanks for yours works!!!