Page 13 of 22

Posted: Tue May 23, 2006 2:26 pm
by zarstar
Are there any method to centre the text when drawing it?

Pratically, I want to write over the head (centrally )of a person his name.
But obviusly, the lenght of the name is variable.

So are there any solution?

Posted: Tue May 23, 2006 5:08 pm
by Emil_halim
New_x_Pos=x_pos-((strlen(text)*charLength)/2)

where
charLength = the second Parameter in CreateFont function.

this will position the text as you want.

Posted: Wed May 24, 2006 12:22 am
by zarstar
First: sorry for all these questions and for my poor English :lol:

I want to know more about the CheckCollide functions:

CheckCollide ( grp_actual_sprite , My_Player.pos_x , My_Player.pos_y , grp_ball , ball.pos_x , ball.pos_y ,1,0)


1) What are the last two parameters?
2) This function check the collide in what mode? pixel by pixel?
3) If not, how can I check a collision between 2 sprites drawed with the alpha method? (alpha key: leaving the background color..)

(I want to check the collision by the SHOES of a soccerplayer and the BALL... I've thinked to separate the shoes sprites by the rest of the body and check the collision with the ball)

Posted: Wed May 24, 2006 4:18 am
by Emil_halim
you are welcome any time.

the last 2 parametres are the retio in x-x and y-y, the CheckCollide function chechs the recangle by rectangle collide ,not pixle by pixle so it is more faster but we need to reduce the rectangle by retio in x-x & y-y direction that you decide to make it more real collide , 0.9 ~ 0.8 are good retio.

Posted: Wed May 24, 2006 9:31 am
by zarstar
I've tried the CheckCollide function, but it isn't good for what I've to do.
Because I need a precisely collision between the soccer-player feets and the ball.

1) Is there any method to enable pixel by pixel collision?
2) or is there any method to check collision between only a part of a sprite? (For example I can check the collision by the down part of the soccer-player sprite, so only the feet check the collision)


Another thing:
Is there any method to color only a part of a sprite colored, for example, by white?
I need it to color the shirt of soccer-player of various colors.

Be patience! ;)

Posted: Wed May 24, 2006 9:56 am
by zarstar
I've thinked to create a simple rectangle sprite, and move it dinamically in the code following the animations (over the feet). So I can check the collision between it and the ball.

What do you think?

The only problem is that I've to move it manually in the code...

Posted: Wed May 24, 2006 2:22 pm
by Emil_halim
i have a selution that may feet your needs.

if you are using Magic2d ver 0.8 ,there is a TMagicSceneNode class, so you could use 2 TMagicSceneNodes to shape your sprite { one for upper part and the other for the feet }, and make the upper as a parent of feet one,then you could only check Collision between the feet and the ball,when the upper part move the feet will move automatically.

Posted: Wed May 24, 2006 9:15 pm
by zarstar
Even this solution doesn't go fine...
Because the TMagicSceneNode it's only a single sprite,
while I need animations (more sprites, like TAnimImage).

However, I need different sprites only for feet, because I want to color them by code (How can I do it? You haven't answered me for that ;) )

PS:
Isn't there any possibility to include pixel by pixel collision?
or other check type collision?

Posted: Thu May 25, 2006 4:24 am
by Emil_halim
ok,i will Make TAnimImageSceneNode next release,but for now, i am thinking in spliting our player sprite into 3part {i mean the 2D Image splits into 3 Part}, one for head ,one for deffrent color body , and finaly one for feet.
BTW any part can be TAnimImage for your desired animation , it will depend on yore artist skill to collect the sprite in good image.
so how could we move the 3 parts in the same time and color any certain part ?

we can do it by relative coordinates just like that
draw Part_1 at (P1_x , P1_Y)
draw part_2 at (P1_x + P2_const_x,p1_y + P2_const_y)
draw Paer_3 at (P1_x + P3_const_x,p1_y + P3_const_y)
so you need only to update P1_x & P1_Y.

when you draw part_2 you could change it's color by setColor function.

i do not know how to do pixel by pixel collision,but i will search the net for best and fast algorithem and see if i can apply it or not.

Hope that will help you.

Posted: Thu May 25, 2006 9:39 am
by zarstar
Ill' wait for you research!

;)

However...thanks for all!
Your work is really great!

Posted: Thu May 25, 2006 10:33 am
by zarstar
Another question:
I have to draw more sprites for one player (head, body, feet).
Is there a method to draw them into a SPRITE and then draw only this sprite??
Or i have to draw every time 3 sprites on the screen?

Posted: Thu May 25, 2006 10:36 am
by zarstar
Another question:
I have to draw more sprites for one player (head, body, feet).
Is there a method to draw them into a SPRITE and then draw only this sprite??
Or i have to draw every time 3 sprites on the screen?

Posted: Thu May 25, 2006 2:35 pm
by Emil_halim
you could put the 3 times drawing in a isolated function and when you want to draw call this function.

Posted: Thu May 25, 2006 3:00 pm
by zarstar
last question for today ;):

I have to load a high number of sprites (I want to make the player much personalizable).
But I've tested that for each file (containing the sprites) I load, it takes a while...

What can I do?

My sprites were .BMP images.
I've tried to convert them to .PNG : I've the same results with less memory space, but with the program it's always the same: much time to load it!

Posted: Thu May 25, 2006 7:02 pm
by Emil_halim
last answer for today :wink:

this belong to Irrlicht it self,so i do not know how to solve this case