Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
1 registered members (Grant), 999 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Giving Sprite from individuall Characters to the function? #319807
04/17/10 22:48
04/17/10 22:48
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
hi there..

ok.. got something special ( for me.. Dunno if it´s special for you...)

i wanted to create a function for animating many 2D Sprites at bone-coordinates (to make animating spritebased charas for a jump´n run easier).

I managed how to get the bone positions and angles.

BUT.. i wanted the function to work global ( means 1 function for all Objects ).
The problem:
I can´t just say:
sprite_a.x = head_pos.x
..etc..

Cause sprite_a is just 1 sprite.. and can only be used by 1 chara.

My question:
Is there a way to give the sprites of the npc/player the function is called from as parameter to the function?


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Giving Sprite from individuall Characters to the function? [Re: Espér] #319808
04/17/10 22:51
04/17/10 22:51
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Erklär bitte noch einmal alternativ auf deutsch, was du versuchst.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Giving Sprite from individuall Characters to the function? [Re: Superku] #319809
04/17/10 23:03
04/17/10 23:03
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
ok.. hab garde ne idee bekommen...

zuerstma die erklärung:

Ich hab ein Sprite, dessen Körper aus lauter einzelparts bsteht ( Kopf, Arme, beine, torso...etc.. alles einzeln ).
Diese Einzelparts würde ich gern allgemein für alle Objekte des gleichen Typs im Spiel mittels einer einzigen Funktion animieren.
Dazu habe ich ein modell, welches nur ein Bone-Skelett enthält.
In der Aktion des Objekts erstelle ich nun die einzelnen Sprites ( dazu dann gleich mehr ), und rufe in einer schleife immer wieder die funktion auf.
Meine alte frage war: wie übergebe ich die Sprites nun für jedes Objekt individuell der Set_Bodypart() Funktion.



Meine idee ist nun:
Ich erstell statt einzelobjekten für die Sprites ein Entity-Array.

Die neue frage | The new Question (sry.. wieder englisch):
How to give an array of entities as parameter in a function?


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Giving Sprite from individuall Characters to the function? [Re: Espér] #319811
04/17/10 23:40
04/17/10 23:40
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Hm ich versteh das Prinzip einfach nicht, befürchte ich.
Dennoch: Du könntest Structs verwenden oder auch nicht:

var anim_objs[100];
var anim_obj_max = 0;

#define kopf skill80
#define bein1 skill81
...

Dann bei Figur-Erstellung:

action figur() {

anim_objs[anim_obj_max] = handle(my);
anim_obj_max++;

you = ent_create(kopf_sprite...)
my.kopf = handle(you);
you = ent_create(bein_sprite...)
my.bein1 = handle(you);

...


Und in deiner Master-Funktion:

while(1) {

for(i = 0; i < anim_obj_max; i++) {
you = ptr_for_handle(anim_objs[i]);
if(you) {
you2 = ptr_for_handle(your.kopf);
you2.x = ...
}
}
wait(1);
}


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Giving Sprite from individuall Characters to the function? [Re: Superku] #319840
04/18/10 10:31
04/18/10 10:31
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
moment..
I have a 2D-Spritecharacter. This Character is made out of several sprites ( 1 headsprite, 2 arms, 2 forarms, 2 hands, 2 legs..etc..)

For this Sprites, i´ve a model that only includes bones.

I´m now creating these sprites inside the model-action:
Code:
ENTITY* bodyparting[24];
bodyparting[0] = ent_create("headsprite", nulling,NULL);
bodyparting[1] = ent_create("brustsprite", nulling,NULL);
..etc..



So.. now i´ve written a function for that spritetype ( 2-leged humanoid ):
Click to reveal..
Code:
function handle_bodyparts()
{
   VECTOR* head_pos = nulling;
   VECTOR* brust_pos = nulling;
   VECTOR* bauch_pos = nulling;
   VECTOR* beinansatz_pos = nulling;
   VECTOR* schulter_l_pos = nulling;
   VECTOR* schulter_r_pos = nulling;
   VECTOR* arm_l_pos = nulling;
   VECTOR* arm_r_pos = nulling;
   VECTOR* hand_l_pos = nulling;
   VECTOR* hand_r_pos = nulling;
   VECTOR* hufte_l_pos = nulling;
   VECTOR* hufte_r_pos = nulling;
   VECTOR* bein_l_pos = nulling;
   VECTOR* bein_r_pos = nulling;
   VECTOR* fuss_l_pos = nulling;
   VECTOR* fuss_r_pos = nulling;
   
   ANGLE* head_ang = nulling;
   ANGLE* brust_ang = nulling;
   ANGLE* bauch_ang = nulling;
   ANGLE* beinansatz_ang = nulling;
   ANGLE* schulter_l_ang = nulling;
   ANGLE* schulter_r_ang = nulling;
   ANGLE* arm_l_ang = nulling;
   ANGLE* arm_r_ang = nulling;
   ANGLE* hand_l_ang = nulling;
   ANGLE* hand_r_ang = nulling;
   ANGLE* hufte_l_ang = nulling;
   ANGLE* hufte_r_ang = nulling;
   ANGLE* bein_l_ang = nulling;
   ANGLE* bein_r_ang = nulling;
   ANGLE* fuss_l_ang = nulling;
   ANGLE* fuss_r_ang = nulling;
   
   
   vec_for_bone(head_pos, my, "Kopf");
   vec_for_bone(brust_pos, my, "Brust");
   vec_for_bone(bauch_pos, my, "Bauch");
   vec_for_bone(beinansatz_pos, my, "Beinansatz");
   vec_for_bone(schulter_l_pos, my, "Schulter_L");
   vec_for_bone(schulter_r_pos, my, "Schulter_R");
   vec_for_bone(arm_l_pos, my, "Arm_L");
   vec_for_bone(arm_r_pos, my, "Arm_R");
   vec_for_bone(hand_l_pos, my, "Hand_L");
   vec_for_bone(hand_r_pos, my, "Hand_R");
   vec_for_bone(hufte_l_pos, my, "Hüfte_L");
   vec_for_bone(hufte_r_pos, my, "Hüfte_R");
   vec_for_bone(bein_l_pos, my, "Bein_L");
   vec_for_bone(bein_r_pos, my, "Bein_R");
   vec_for_bone(fuss_l_pos, my, "Fuß_L");
   vec_for_bone(fuss_r_pos, my, "Fuß_R");
   
   ang_for_bone(head_ang, my, "Kopf");
   ang_for_bone(brust_ang, my, "Brust");
   ang_for_bone(bauch_ang, my, "Bauch");
   ang_for_bone(beinansatz_ang, my, "Beinansatz");
   ang_for_bone(schulter_l_ang, my, "Schulter_L");
   ang_for_bone(schulter_r_ang, my, "Schulter_R");
   ang_for_bone(arm_l_ang, my, "Arm_L");
   ang_for_bone(arm_r_ang, my, "Arm_R");
   ang_for_bone(hand_l_ang, my, "Hand_L");
   ang_for_bone(hand_r_ang, my, "Hand_R");
   ang_for_bone(hufte_l_ang, my, "Hüfte_L");
   ang_for_bone(hufte_r_ang, my, "Hüfte_R");
   ang_for_bone(bein_l_ang, my, "Bein_L");
   ang_for_bone(bein_r_ang, my, "Bein_R");
   ang_for_bone(fuss_l_ang, my, "Fuß_L");
   ang_for_bone(fuss_r_ang, my, "Fuß_R");
   
   //Spriteanpassung ab hier
   //Spritesetting
}



My question now:
How the parameter for the function has to look like?
i tried
Code:
function handle_bodyparts(ENTITY* parts[24])



But that´s not working.. i always get "wrong number/type of arguments"


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Giving Sprite from individuall Characters to the function? [Re: Espér] #319850
04/18/10 11:52
04/18/10 11:52
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Normalerweise müsste die Funktion als Parameter bodyparts(ENTITY* parts) haben, aber das scheint nicht zu funktionieren. Kann ich leider nicht beantworten.
Als Alternative kannst du natürlich ein handle-var-array verwenden und das übergeben, um in der Funktion mit ptr_for_handle die Entities wiederherzustellen.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Giving Sprite from individuall Characters to the function? [Re: Superku] #319859
04/18/10 12:12
04/18/10 12:12
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Maybe, something like a struct serves that purpose as described by George in AUM 83 -> Plug and Play -> Lite-C structs.

Every Bone has the same pos/angle??? HELP [Re: Pappenheimer] #319884
04/18/10 16:07
04/18/10 16:07
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
oo..kay..

i got the struct for the bodyparts to work.

But got a new problem...
This is the bodypart function:
Click to reveal..
Code:
function handle_bodyparts(MODEL* own)
{
	my = own.mainchar;
	VECTOR* head_pos = nulling;
	VECTOR* brust_pos = nulling;
	VECTOR* bauch_pos = nulling;
	VECTOR* beinansatz_pos = nulling;
	VECTOR* schulter_l_pos = nulling;
	VECTOR* schulter_r_pos = nulling;
	VECTOR* arm_l_pos = nulling;
	VECTOR* arm_r_pos = nulling;
	VECTOR* arm_l2_pos = nulling;
	VECTOR* arm_r2_pos = nulling;
	VECTOR* hand_l_pos = nulling;
	VECTOR* hand_r_pos = nulling;
	VECTOR* hufte_l_pos = nulling;
	VECTOR* hufte_r_pos = nulling;
	VECTOR* bein_l_pos = nulling;
	VECTOR* bein_r_pos = nulling;
	VECTOR* bein_l2_pos = nulling;
	VECTOR* bein_r2_pos = nulling;
	VECTOR* fuss_l_pos = nulling;
	VECTOR* fuss_r_pos = nulling;
	
	ANGLE* head_ang = nulling;
	ANGLE* brust_ang = nulling;
	ANGLE* bauch_ang = nulling;
	ANGLE* beinansatz_ang = nulling;
	ANGLE* schulter_l_ang = nulling;
	ANGLE* schulter_r_ang = nulling;
	ANGLE* arm_l_ang = nulling;
	ANGLE* arm_r_ang = nulling;
	ANGLE* arm_l2_ang = nulling;
	ANGLE* arm_r2_ang = nulling;
	ANGLE* hand_l_ang = nulling;
	ANGLE* hand_r_ang = nulling;
	ANGLE* hufte_l_ang = nulling;
	ANGLE* hufte_r_ang = nulling;
	ANGLE* bein_l_ang = nulling;
	ANGLE* bein_r_ang = nulling;
	ANGLE* bein_l2_ang = nulling;
	ANGLE* bein_r2_ang = nulling;
	ANGLE* fuss_l_ang = nulling;
	ANGLE* fuss_r_ang = nulling;
	
	
	vec_for_bone(head_pos, my, "Kopf");
	vec_for_bone(brust_pos, my, "Brust");
	vec_for_bone(bauch_pos, my, "Bauch");
	vec_for_bone(beinansatz_pos, my, "Beinansatz");
	vec_for_bone(schulter_l_pos, my, "Schulter_L");
	vec_for_bone(schulter_r_pos, my, "Schulter_R");
	vec_for_bone(arm_l_pos, my, "Arm_L");
	vec_for_bone(arm_r_pos, my, "Arm_R");
	vec_for_bone(arm_l2_pos, my, "Arm_L1");
	vec_for_bone(arm_r2_pos, my, "Arm_R1");
	vec_for_bone(hand_l_pos, my, "Hand_L");
	vec_for_bone(hand_r_pos, my, "Hand_R");
	vec_for_bone(hufte_l_pos, my, "Hüfte_L");
	vec_for_bone(hufte_r_pos, my, "Hüfte_R");
	vec_for_bone(bein_l_pos, my, "Bein_L");
	vec_for_bone(bein_r_pos, my, "Bein_R");
	vec_for_bone(bein_l2_pos, my, "Bein_L1");
	vec_for_bone(bein_r2_pos, my, "Bein_R1");
	vec_for_bone(fuss_l_pos, my, "Fuß_L");
	vec_for_bone(fuss_r_pos, my, "Fuß_R");
	
	//vvvvvvvvvvvvvv DEBUG ERROR vvvvvvvvvvvvvvvv
	STRING* pos = "#100";
	STRING* pos2 = "#100";
	str_cpy(pos, "Position Beinbone: ");
	str_for_num(pos2, bein_l_pos.x);
	str_cat(pos, pos2);
	str_cat(pos, ", ");
	str_for_num(pos2, bein_l_pos.y);
	str_cat(pos, pos2);
	str_cat(pos, ", ");
	str_for_num(pos2, bein_l_pos.z);
	str_cat(pos, pos2);
	str_cat(pos, "  |  ");
	str_for_num(pos2, bein_r_pos.x);
	str_cat(pos, pos2);
	str_cat(pos, ", ");
	str_for_num(pos2, bein_r_pos.y);
	str_cat(pos, pos2);
	str_cat(pos, ", ");
	str_for_num(pos2, bein_r_pos.z);
	str_cat(pos, pos2);
	str_cat(pos, "\n");
	str_cat(pos, "Position Fußbone: ");
	str_for_num(pos2, fuss_l_pos.x);
	str_cat(pos, pos2);
	str_cat(pos, ", ");
	str_for_num(pos2, fuss_l_pos.y);
	str_cat(pos, pos2);
	str_cat(pos, ", ");
	str_for_num(pos2, fuss_l_pos.z);
	str_cat(pos, pos2);
	str_cat(pos, "  |  ");
	str_for_num(pos2, fuss_r_pos.x);
	str_cat(pos, pos2);
	str_cat(pos, ", ");
	str_for_num(pos2, fuss_r_pos.y);
	str_cat(pos, pos2);
	str_cat(pos, ", ");
	str_for_num(pos2, fuss_r_pos.z);
	str_cat(pos, pos2);
	error(pos);
	//^^^^^^^^^^^^^^ DEBUG ERROR ^^^^^^^^^^^^^^
	
	
	ang_for_bone(head_ang, my, "Kopf");
	ang_for_bone(brust_ang, my, "Brust");
	ang_for_bone(bauch_ang, my, "Bauch");
	ang_for_bone(beinansatz_ang, my, "Beinansatz");
	ang_for_bone(schulter_l_ang, my, "Schulter_L");
	ang_for_bone(schulter_r_ang, my, "Schulter_R");
	ang_for_bone(arm_l_ang, my, "Arm_L");
	ang_for_bone(arm_r_ang, my, "Arm_R");
	ang_for_bone(arm_l2_ang, my, "Arm_L1");
	ang_for_bone(arm_r2_ang, my, "Arm_R1");
	ang_for_bone(hand_l_ang, my, "Hand_L");
	ang_for_bone(hand_r_ang, my, "Hand_R");
	ang_for_bone(hufte_l_ang, my, "Hüfte_L");
	ang_for_bone(hufte_r_ang, my, "Hüfte_R");
	ang_for_bone(bein_l_ang, my, "Bein_L");
	ang_for_bone(bein_r_ang, my, "Bein_R");
	ang_for_bone(bein_l2_ang, my, "Bein_L1");
	ang_for_bone(bein_r2_ang, my, "Bein_R1");
	ang_for_bone(fuss_l_ang, my, "Fuß_L");
	ang_for_bone(fuss_r_ang, my, "Fuß_R");
	
	//Spriteanpassung ab hier
	//Spritesetting
	if(own.body_ok[0] == 1){vec_set(own.kopf.x, head_pos.x); vec_set(own.kopf.pan, head_ang.pan);}
	
	if(own.body_ok[10] == 1){vec_set(own.bein_a.x, bein_l_pos.x); vec_set(own.bein_a.pan, bein_l_ang.pan); own.bein_a.tilt = 0.01; own.bein_a.pan = -90+my.pan;}
	if(own.body_ok[11] == 1){vec_set(own.bein_b.x, bein_l2_pos.x); vec_set(own.bein_b.pan, bein_l2_ang.pan); own.bein_b.tilt = 0.01; own.bein_b.pan = -90+my.pan;}
	if(own.body_ok[12] == 1){vec_set(own.bein_a2.x, bein_r_pos.x); vec_set(own.bein_a2.pan, bein_r_ang.pan); own.bein_a2.tilt = 0.01; own.bein_a2.pan = -90+my.pan;}
	if(own.body_ok[13] == 1){vec_set(own.bein_b2.x, bein_r2_pos.x); vec_set(own.bein_b2.pan, bein_r2_ang.pan); own.bein_b2.tilt = 0.01; own.bein_b2.pan = -90+my.pan;}
	if(own.body_ok[14] == 1){vec_set(own.fuss.x, fuss_l_pos.x); vec_set(own.fuss.pan, fuss_l_ang.pan); own.fuss.tilt = 0.01; own.fuss.pan = -90+my.pan;}
	if(own.body_ok[15] == 1){vec_set(own.fuss2.x, fuss_r_pos.x); vec_set(own.fuss2.pan, fuss_r_ang.pan); own.fuss2.tilt = 0.01; own.fuss2.pan = -90+my.pan;}
}



What i wanna do there:
Set the bodypart-sprites at the position/angle of the bones.

But ingame, the sprites are all at the same position.
So i added the debug error to check the bone position of 4 sprites (leg_l/r and foot_l/r).
And.. they have all the same position...


Why is vec_for_bone ang_for_bone not setting the vectors/angles???


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Every Bone has the same pos/angle??? HELP [Re: Espér] #320038
04/19/10 14:04
04/19/10 14:04
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
ah.. ok.. i managed to give the structobject to the function.. like this:
Code:
function handle_bodyparts(MODEL* own)
{
	my = own.mainchar;
	
	//Spriteanpassung ab hier
	//Spritesetting
	if(own.body_ok[0] == 1){vec_for_bone(own.kopf.x, my, "Kopf"); ang_for_bone(own.kopf.pan, my, "Kopf");}
	
	if(own.body_ok[10] == 1){vec_for_bone(own.bein_a.x, my, "Bein_L"); ang_for_bone(own.bein_a.pan, my, "Bein_L"); own.bein_a.tilt = 0.01; own.bein_a.pan -= 90;}
	if(own.body_ok[11] == 1){vec_for_bone(own.bein_b.x, my, "Bein_L1"); ang_for_bone(own.bein_b.pan, my, "Bein_L1"); own.bein_b.tilt = 0.01; own.bein_b.pan -= 90;}
	if(own.body_ok[12] == 1){vec_for_bone(own.bein_a2.x, my, "Bein_R"); ang_for_bone(own.bein_a2.pan, my, "Bein_R"); own.bein_a2.tilt = 0.01; own.bein_a2.pan -= 90;}
	if(own.body_ok[13] == 1){vec_for_bone(own.bein_b2.x, my, "Bein_R1"); ang_for_bone(own.bein_b2.pan, my, "Bein_R1"); own.bein_b2.tilt = 0.01; own.bein_b2.pan -= 90;}
	if(own.body_ok[14] == 1){vec_for_bone(own.fuss.x, my, "Fuß_L"); ang_for_bone(own.fuss.pan, my, "Fuß_L"); own.fuss.tilt = 0.01; own.fuss.pan -= 90;}
	if(own.body_ok[15] == 1){vec_for_bone(own.fuss2.x, my, "Fuß_R"); ang_for_bone(own.fuss2.pan, my, "Fuß_R"); own.fuss2.tilt = 0.01; own.fuss2.pan -= 90;}
}



vec_for_bone works great.. but..

ang_for_bone seems not to work Y_Y


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1