Prowler Productions
  Dink Smallwood Forum
  characters moving

Post New Topic  
profile | register | faq

Author Topic:   characters moving
joshriot posted 01-19- 12:30 PM CT (US)   Click Here to See the Profile for joshriot   Click Here to Email joshriot  
i want to make a character that can only move horizontal and not vertical. how do i make it do this?
Tamtur posted 01-19- 12:54 PM CT (US)     Click Here to See the Profile for Tamtur  Click Here to Email Tamtur     
I don't know if there's an easier way to do this, but in the original code for punching, it has the following script - it takes care of diagonals, so Dink can only punch horizontally or vertically:

if (sp_dir(1, -1) == 1)
sp_dir(1, 2);
if (sp_dir(1, -1) == 3)
sp_dir(1, 2);
if (sp_dir(1, -1) == 7)
sp_dir(1, 8);
if (sp_dir(1, -1) == 9)
sp_dir(1, 8);

You would have to add a couple lines to take care of vertical movement, of course.

Good luck

Tamtur

joshriot posted 01-19- 05:27 PM CT (US)     Click Here to See the Profile for joshriot  Click Here to Email joshriot     
i dont follow
redink1 posted 01-19- 05:59 PM CT (US)     Click Here to See the Profile for redink1  Click Here to Email redink1     
Make your own brain. Change randx's value as appropriate.

void main(void)
{
//Base walk stuff
int &randx;
int &currx;
loop:
&randx = random(100,400);
&currx = sp_x(& current_sprite, -1);
if (&randx > &currx) move_stop(& current_sprite, &randx, 6, 1);
if (&randx < &currx) move_stop(& current_sprite, &randx, 46, 1);
wait(1);
goto loop;
}

void talk(void)
{
freeze(& current_sprite);
//say stuff
goto loop;
}

joshriot posted 01-19- 06:00 PM CT (US)     Click Here to See the Profile for joshriot  Click Here to Email joshriot     
i tried putting this into main(void)

if (sp_dir((¤t_sprite, -1) == 1)
sp_dir(¤t_sprite, 2);
if (sp_dir(¤t_sprite, -1) == 2)
sp_dir(¤t_sprite, 6);
if (sp_dir(¤t_sprite, -1) == 3)
sp_dir(¤t_sprite, 2);
if (sp_dir(¤t_sprite, -1) == 7)
sp_dir(¤t_sprite, 8);
if (sp_dir(¤t_sprite, -1) == 8)
sp_dir(¤t_sprite, 4);
if (sp_dir(¤t_sprite, -1) == 9)
sp_dir(¤t_sprite, 8);

but it didnt work. could you tell me whats going wrong?

joshriot posted 01-19- 06:01 PM CT (US)     Click Here to See the Profile for joshriot  Click Here to Email joshriot     
okay i understand that, sort of, but whats the void talk for?
joshriot posted 01-19- 06:08 PM CT (US)     Click Here to See the Profile for joshriot  Click Here to Email joshriot     
this is what i have for it now but it dosnt work


void main( void )
{
sp_speed(¤t_sprite, 10);
sp_exp(¤t_sprite, 5);
sp_base_walk(¤t_sprite, 860);
sp_base_death(¤t_sprite, 870);
sp_touch_damage(¤t_sprite, 8);
sp_hitpoints(¤t_sprite, 50);
sp_flying(¤t_sprite, 1);
sp_move_nohard(¤t_sprite, 1);

int &randx;
int &currx;
loop:
&randx = random(100,400);
&currx = sp_x(& current_sprite, -1);
if (&randx > &currx) move_stop(& current_sprite, &randx, 6, 1);
if (&randx < &currx) move_stop(& current_sprite, &randx, 46, 1);
wait(1);
goto loop;
}

void hit( void )
{
sp_target(¤t_sprite, &enemy_sprite);
playsound(30, 21050, 4000, ¤t_sprite, 0);
}
void die( void )
{
int &hold = sp_editor_num(¤t_sprite);
if (&hold != 0)
editor_type(&hold, 6);

&save_x = sp_x(¤t_sprite, -1);
&save_y = sp_y(¤t_sprite, -1);

external("emake","small");

}

someone2 posted 01-20- 03:02 AM CT (US)     Click Here to See the Profile for someone2  Click Here to Email someone2     
Yeah, I created a sprite to do that. He just walks back and forth (for my LOS system in RS):

walk:
move_stop(¤t_sprite,4,120,1);
move_stop(¤t_sprite,6,550,1);
goto walk;

redink1 posted 01-20- 12:18 PM CT (US)     Click Here to See the Profile for redink1  Click Here to Email redink1     
In the second if (&randx < &currx) change 46 to 4 (my stupid mistake). And after playsound in void hit(void) add a goto loop; line (because the sprite will enter out of the loop whenever you do anything to it, which is why I added the talk stuff because I thought you might talk to it).
joshriot posted 01-20- 10:51 PM CT (US)     Click Here to See the Profile for joshriot  Click Here to Email joshriot     
okay i understand, so if the sprite does something the loop stops and it does it, then i need to make it start the loop again. i will try it out and see how it works, thanks.
joshriot posted 01-20- 11:15 PM CT (US)     Click Here to See the Profile for joshriot  Click Here to Email joshriot     
heres what ive got now but it still dosnt work. the sprite just sits there, dosnt move at all, and when i touch it i get dealt damage but when i try to hit it it does not get hurt. should the loop be under main (void) or something else or do i have the base walk set up wrong? i have two pics of the sprite, one facing left and one facing right set under 864 and 866. i really dont know why its not working.


void main( void )
{
sp_speed(¤t_sprite, 10);
sp_exp(¤t_sprite, 5);
sp_base_walk(¤t_sprite, 860);
sp_base_death(¤t_sprite, 870);
sp_touch_damage(¤t_sprite, 8);
sp_hitpoints(¤t_sprite, 50);
sp_flying(¤t_sprite, 1);
sp_move_nohard(¤t_sprite, 1);

int &randx;
int &currx;
loop:
&randx = random(100,400);
&currx = sp_x(¤t_sprite, -1);
if (&randx > &currx) move_stop(¤t_sprite, &randx, 6, 1);
if (&randx < &currx) move_stop(¤t_sprite, &randx, 4, 1);
wait(1);
goto loop;
}

void hit( void )
{
sp_target(¤t_sprite, &enemy_sprite);
playsound(30, 21050, 4000, ¤t_sprite, 0);
goto loop;
}
void die( void )
{
int &hold = sp_editor_num(¤t_sprite);
if (&hold != 0)
editor_type(&hold, 6);

&save_x = sp_x(¤t_sprite, -1);
&save_y = sp_y(¤t_sprite, -1);

external("emake","small");

}

someone2 posted 01-21- 01:25 AM CT (US)     Click Here to See the Profile for someone2  Click Here to Email someone2     
You should be using sp_mx().
Nexis posted 01-21- 05:10 AM CT (US)     Click Here to See the Profile for Nexis  Click Here to Email Nexis     
Perhaps you should put the statements following the if statement on a separate line and see if that works. Only thing I can think of. Why should he use sp_mx() Someone?
joshriot posted 01-21- 10:40 AM CT (US)     Click Here to See the Profile for joshriot  Click Here to Email joshriot     
nexis i tried changing it like so but it does the same thing as before. could someone explain this sp_mx() to me please?

void main( void )
{
int &randx;
int &currx;
sp_speed(¤t_sprite, 10);
sp_exp(¤t_sprite, 5);
sp_base_walk(¤t_sprite, 860);
sp_base_death(¤t_sprite, 870);
sp_touch_damage(¤t_sprite, 8);
sp_hitpoints(¤t_sprite, 50);
sp_flying(¤t_sprite, 1);
sp_move_nohard(¤t_sprite, 1);

loop:
&randx = random(100,400);
&currx = sp_x(¤t_sprite, -1);
if (&randx > &currx)
{
move_stop(¤t_sprite, &randx, 6, 1);
}
if (&randx < &currx)
{
move_stop(¤t_sprite, &randx, 4, 1);
}
wait(1);
goto loop;
}

void hit( void )
{
sp_target(¤t_sprite, &enemy_sprite);
playsound(30, 21050, 4000, ¤t_sprite, 0);
goto loop;
}
void die( void )
{
int &hold = sp_editor_num(¤t_sprite);
if (&hold != 0)
editor_type(&hold, 6);
&save_x = sp_x(¤t_sprite, -1);
&save_y = sp_y(¤t_sprite, -1);
external("emake","small");
}

Tamtur posted 01-21- 04:12 PM CT (US)     Click Here to See the Profile for Tamtur  Click Here to Email Tamtur     
I think it is your random statement that is causing the problem. In the dinkc text, it says:
Random(10,1) would return a number between 1 and 10. Random(5,0) would return a number from 0 to 4. Simular to how C does it.

So I think it should be
&randx = random(400, 100);

To check it, though, you can add a debug line to find out what the random number is:
debug("the random number is &randx");
or some such thing.

someone2 posted 01-21- 07:55 PM CT (US)     Click Here to See the Profile for someone2  Click Here to Email someone2     
Random(400,100) will give you a number beween 500-100.

He should be using sp_mx, as how is he currently using move_stop isn't right. move_stop requires the exact coordinates, and not in relation to the sprite's origin.

Nexis posted 01-21- 10:09 PM CT (US)     Click Here to See the Profile for Nexis  Click Here to Email Nexis     
Only problem with that Someone is that the sprite might wander off the screen.
Beuc posted 01-22- 10:46 AM CT (US)     Click Here to See the Profile for Beuc  Click Here to Email Beuc     
Here's a working code :)
I created a Milder, set its base_walk and attributes,
and attached this to him.


void main(void)
{
sp_speed(&current_sprite, 10);
sp_exp(&current_sprite, 5);
// sp_base_walk(&current_sprite, 860);
sp_base_death(&current_sprite, 870);
sp_touch_damage(&current_sprite, 8);
sp_hitpoints(&current_sprite, 50);
// sp_flying(&current_sprite, 1);
// sp_move_nohard(&current_sprite, 1);
loop:
if (sp_dir(&current_sprite, -1) == 1)
sp_dir(&current_sprite, 4);
if (sp_dir(&current_sprite, -1) == 2)
sp_dir(&current_sprite, 6);
if (sp_dir(&current_sprite, -1) == 3)
sp_dir(&current_sprite, 6);
if (sp_dir(&current_sprite, -1) == 7)
sp_dir(&current_sprite, 4);
if (sp_dir(&current_sprite, -1) == 8)
sp_dir(&current_sprite, 4);
if (sp_dir(&current_sprite, -1) == 9)
sp_dir(&current_sprite, 6);
wait(0);
goto loop;
}

void hit( void )
{
sp_target(&current_sprite, &enemy_sprite);
playsound(30, 21050, 4000, ¤t_sprite, 0);
goto loop;
}

void die( void )
{
int &hold = sp_editor_num &current_sprite);
if (&hold != 0)
editor_type(&hold, 6);
&save_x = sp_x(&current_sprite, -1);
&save_y = sp_y(&current_sprite, -1);
external("emake","small");
}


It run quite well but if he's hurt, he doesn't "follow" Dink...
Maybe you'll have to make a different loop for hit(), where
you set its direction related to Dink's one: if Dink's left,
Milder's direction will be left, and so on.
I also tried with your original seq, but as they doesn't
exists in my sample DMOD, there was a problem, and
the anim was chaotic.

Good Luck! :)

Beuc posted 01-24- 04:07 AM CT (US)     Click Here to See the Profile for Beuc  Click Here to Email Beuc     
Hey!
You couuld tell us if this works :)

Post New Topic  Post Reply
Hop to:


Contact Us | Prowler Productions

Powered by: Ultimate Bulletin Board, Freeware Version 5.10a
Purchase our Licensed Version- which adds many more features!
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 2000.