Jump to content


StopThatGuy

Member Since 13 Jul 2006
Offline Last Active Mar 31 2013 11:46 AM

Topics I've Started

Ai Moving - Whats Wrong With My Code?

27 March 2013 - 01:46 AM

Hi guys, I'm just making a really basic AI that goes back between left and right, however when I'm using this code...

 

Create:

dir=choose(-1,1)
alarm[1]=30;

Alarm 1:

if dir=-1
{
dir=1
alarm[1]=30;
}
if dir=1
{
dir=-1
alarm[1]=30;
}

Step:

if dir=-1
{
hspeed+=0.4
}
if dir=1
{
hspeed-=0.4
}
 
if hspeed>3
{
hspeed=3
}
if hspeed<-3
{
hspeed=-3
}

 

... It doesn't work properly. It just keeps going right. Some of the ones that start left curve back into right, but then it just keeps going off to the right.

 

Any solutions?

 

EDIT: Reformatted post.


Draw Issues

27 July 2009 - 07:58 AM

Hey guys, I seem to be having a draw probem with my player object.
Whenever I start my game, I always get this error right at the start:

___________________________________________
ERROR in
action number 1
of Draw Event
for object obj_player:

Trying to draw non-existing sprite.


And some observations have noticed that this line of code is the cause:
draw_sprite_ext(guns,image_index,x+lengthdir_x(9,direction),y+lengthdir_y(9,direction),1,1,image_angle,image_blend,image_alpha)
I've figured out why its doing it, the sprite is calling for a variable, but its being called first before the the variable is actually set, as the variable 'guns' is set in the Create event of the object.

My question is though, what would I be able to do so it sets the variable before it tries to draw? I've tried setting the variable in the draw event, but the sprite I set remains in front of the player no matter what and doesn't change. Anyone got any other ideas?

Choosing Codes

08 June 2009 - 11:15 AM

Hey guys.
I'm having a bit of trouble getting this to work properly, what I'm trying to get at is when my enemy collides with another object I want it to randomly choose between some sounds, like for example, an enemy getting shot. As I have multiple sounds for getting hit, I want it to choose another sound randomly each time it gets shot.

I've got this as my code atm:

In collision event:

choose(sound_play(snd_bloodsplat),sound_play(snd_bloodsplat2))
choose(sound_play(snd_hit),sound_play(snd_hit2),sound_play(snd_hit3))

Unfortunately this doesn't work, it only plays the last sounds in each line of code, so the 1st line only plays snd_bloodsplat2 and the 2nd line only plays snd_hit3

Does anyone know how this would work properly? I've thought about calling a random number and assigning a sound_play with it, but I'm not sure how I would check it properly. Any help would be nice.

Whats Wrong With This Code?

29 December 2007 - 04:48 AM

My friend's trying to make a program to run servers off from, he keeps getting this error though.

ERROR in
action number 1
of  Step Event
for object server:

Error in code at line 17:
       with(player[playerid])

at position 11: Unknown variable player or array index out of bounds

Now heres that section of the coding

Go down to 3rd page for source.


Can anyone see something wrong with this? I think theres something wrong with checking if so and so exist.

Mirror Sprite

28 December 2007 - 04:11 AM

Is there a way to mirror a sprite in-game with coding? Like you just have 1 sprite facing 1 direction and if you move left it will mirror it to face that direction, etc etc?

image_angle wouldn't work I don't think, that would flip it upside down.