here is my step code.
image_index = direction * 8/360; image_speed =1; draw_sprite_ext(spr_farmer,(8*image_index)+(image_angle/360),x,y,image_xscale,image_yscale,image_angle,c_white,0)
thanks so much for your time.
Posted 27 February 2012 - 12:38 AM
image_index = direction * 8/360; image_speed =1; draw_sprite_ext(spr_farmer,(8*image_index)+(image_angle/360),x,y,image_xscale,image_yscale,image_angle,c_white,0)
Posted 27 February 2012 - 12:47 AM
Posted 27 February 2012 - 01:25 AM
he is still sliding in the correct direction but the walking animation is still not playing.To do his animation, wouldn't you remove the whole equation and just make it image_index for the second argument?
draw_sprite_ext(spr_farmer,image_index,x,y,image_xscale,image_yscale,image_angle,c_white,0);
Posted 27 February 2012 - 01:46 AM
Posted 27 February 2012 - 02:11 AM
it is set to 1. i had all the code in the step event. i tried this:OH, is your image_speed set somewhere to 0? You have to set that to something like 0.4 when you start walking, then 0 again when you aren't...
depth = -y;
image_index = direction * 8/360;
image_speed =0.4;step eventdraw_sprite_ext(spr_wheat_farmer,image_index,x,y,image_xscale,image_yscale,image_angle,c_white,0);but now he just spins in a circle following the path :/
Edited by fylith, 27 February 2012 - 02:18 AM.
Posted 27 February 2012 - 02:24 AM
Also, draw_sprite_ext doesn't work in the step event (all drawing codes need to be in the draw event)... but you don't need it either, as Game Maker automatically draws it according to image_index and image angle.here is my step code.
image_angle = direction;
Edited by torigara, 27 February 2012 - 02:25 AM.
Posted 27 February 2012 - 02:36 AM
when I do that he still spins but now he is flatened not iso. here is my game can you look at it and see what i screwed up onSince you're using image_angle, you don't have to use direction to calculate image_index either.
Also, draw_sprite_ext doesn't work in the step event (all drawing codes need to be in the draw event)... but you don't need it either, as Game Maker automatically draws it according to image_index and image angle.here is my step code.
All you need was this in the step event and leave image_index as is (so it is automatically updated according to image_speed.)image_angle = direction;
Posted 27 February 2012 - 08:39 AM
Edited by torigara, 27 February 2012 - 08:45 AM.
Posted 27 February 2012 - 11:24 AM
spr_wheat_farmer i moved the sequences to have them match every 8th IE his walk down animation is 8 pics away. but the spr_farmer is un_manipulated it has the animations in the correct order but when i changed obj_wheat_farmer to have the sprite spr_farmer it is still doing the same spinning and flattened image.Well, your sprite seem to have neither a sequence of animation nor a sequence of rotated images. They're some sort of combination of animation and rotation that I can't figure out how they're organized. Can you explain which sub-images are supposed to be used in which direction?
Posted 28 February 2012 - 03:30 AM
So, they're supposed to be used as follows, right?spr_wheat_farmer i moved the sequences to have them match every 8th IE his walk down animation is 8 pics away.
Direction Sub-images used ------------------------------------------ East 0, 8, 16, 24, 32, 40, 48, 56 North-East 1, 9, 17, 25, 33, 41, 49, 57 North 2, 10, 18, 26, 34, 42, 50, 58 ... South 6, 14, 22, 30, 38, 46, 54, 62 South-East 7, 15, 23, 31, 39, 47, 55, 63I'm afraid your sequence if broken somewhere, because the last sub-image 63 doesn't look to face south-east (315) but south-west (225.) But let's go along with this assumption.
// Create event frame_no = 0; // A variable to keep track of animation image_speed = 0; // We don't (and can't) use the in-built speed
row_no = round(direction / 45);
if (row_no == 8) row_no = 0; // for direction between 337.5 and 360
frame_no = (frame_no + 0.4) mod 8; // Change 0.4 to your desired image speed
Turn the frame number into a column number in the above table (0 to 7.)col_no = floor(frame_no);
Multiplying the column number by 8 and adding the row number yields the desired sub-image index.image_index = col_no * 8 + row_no;
// Step event frame_no = (frame_no + 0.4) mod 8; // Change 0.4 to your desired image speed image_index = floor(frame_no) * 8 + round(direction / 45) mod 8;
Edited by torigara, 28 February 2012 - 06:10 AM.
Posted 28 February 2012 - 12:30 PM
i have a sprite with the sequence east = 0-7 and so on. what is the easier version you talked about? the one above got his animations going but he is not facing the correct directions nowSo, they're supposed to be used as follows, right?
Direction Sub-images used ------------------------------------------ East 0, 8, 16, 24, 32, 40, 48, 56 North-East 1, 9, 17, 25, 33, 41, 49, 57 North 2, 10, 18, 26, 34, 42, 50, 58 ... South 6, 14, 22, 30, 38, 46, 54, 62 South-East 7, 15, 23, 31, 39, 47, 55, 63I'm afraid your sequence if broken somewhere, because the last sub-image 63 doesn't look to face south-east (315) but south-west (225.) But let's go along with this assumption.
The thing could be easier if the column and row were swapped (i.e. sub-images 0 to 7 were used for east, 8 to 15 were north-east and so on.) Unfortunately, sub-image numbers are discontinuous within an animation with the current setup, so we need our own variable to keep track of the animation.// Create event frame_no = 0; // A variable to keep track of animation image_speed = 0; // We don't (and can't) use the in-built speed
To calculate the image index, we first calculate the row number in the above table from the direction (east=0, north-east=1 and so on.)row_no = round(direction / 45);
Since each animation sequence consists of 8 sub-images, we update the frame number keeping it between 0 (inclusive) and 8 (exclusive).
if (row_no == 8) row_no = 0; // for direction between 337.5 and 360frame_no = (frame_no + 0.4) mod 8; // Change 0.4 to your desired image speed
Turn the frame number into a column number in the above table (0 to 7.)col_no = floor(frame_no);
Multiplying the column number by 8 and adding the row number yields the desired sub-image index.image_index = col_no * 8 + row_no;
Now add those expressions together, making a bit of simplification.// Step event frame_no = (frame_no + 0.4) mod 8; // Change 0.4 to your desired image speed image_index = floor(frame_no) * 8 + round(direction / 45) mod 8;
Posted 29 February 2012 - 01:43 AM
image_index = row_no * 8 + col_no;
What have you tried so far?Edited by torigara, 29 February 2012 - 04:57 AM.
Posted 29 February 2012 - 05:13 AM
I've explained how the code is derived step by step. If you arrange sub-images so that it advances in the column order first, you could just swap col_no and row_no in the expression, say:
image_index = row_no * 8 + col_no;
What have you tried so far?
create code: frame_no = 0; // A variable to keep track of animation image_speed = 0; // We don't (and can't) use the in-built speed step code: //this one was the one that i think i changed the col_num with row_num frame_no = (frame_no + 0.4) //mod 8; // Change 0.4 to your desired image speed image_index = floor(frame_no) + round(direction / 45) //mod 8; // frame_no = (frame_no + 0.4) mod 8; // Change 0.4 to your desired image speed image_index = round(direction / 45)+ floor(frame_no) mod 8; // and i have tried frame_no = (frame_no + 0.4) //mod 8; // Change 0.4 to your desired image speed image_index = floor(frame_no) + round(direction / 45) //mod 8; //and frame_no = (frame_no + 0.4) //mod 8; // Change 0.4 to your desired image speed image_index = floor(frame_no) * round(direction / 45) //mod 8; //and frame_no = (frame_no + 0.4) mod 4; // Change 0.4 to your desired image speed image_index = floor(frame_no) + round(direction / 45) mod 4;
Posted 01 March 2012 - 01:19 AM
row_no = round(direction / 45) mod 8; // A simplified expression
col_no = floor(frame_no);
image_index = row_no * 8 + col_no
= (round(direction / 45) mod 8) * 8 + floor(frame_no)
frame_no = (frame_no + 0.4) mod 8; // Change 0.4 to your desired image speed image_index = (round(direction / 45) mod 8) * 8 + frame_no;And make sure that ALL of your sub-images are correctly arranged as indicated below, with no exception.
Direction Sub-images used --------------------------- East 0 to 7 North-East 8 to 15 North 16 to 23 North-West 24 to 31 West 32 to 39 South-West 40 to 47 South 48 to 55 South-East 56 to 63
Posted 01 March 2012 - 02:03 AM
wow i am so sorry i don't know how i missed that i will try it right now.You seem to have missed "* 8" part altogether. Well, let's recall...
row_no = round(direction / 45) mod 8; // A simplified expression
Substitute these two for the third expression:
col_no = floor(frame_no);image_index = row_no * 8 + col_no
Sub-images are now continous within an animation, so we no longer have to make col_no a whole number. But it still has to be kept between 0 (inclusive) and 8 (exclusive). You were not supposed to change the first line.
= (round(direction / 45) mod 8) * 8 + floor(frame_no)frame_no = (frame_no + 0.4) mod 8; // Change 0.4 to your desired image speed image_index = (round(direction / 45) mod 8) * 8 + frame_no;And make sure that ALL of your sub-images are correctly arranged as indicated below, with no exception.Direction Sub-images used --------------------------- East 0 to 7 North-East 8 to 15 North 16 to 23 North-West 24 to 31 West 32 to 39 South-West 40 to 47 South 48 to 55 South-East 56 to 63
Edited by fylith, 01 March 2012 - 02:21 AM.
0 members, 0 guests, 0 anonymous users