Jump to content


Photo

particles/variable question


  • Please log in to reply
4 replies to this topic

#1 GreenhornGames

GreenhornGames

    GMC Member

  • GMC Member
  • 730 posts
  • Version:GM8

Posted 17 April 2012 - 12:50 PM

1. how do you make particles constantly producing at objects position? (cuz im trying to do an sparkle effect)

2. can you increase movement of player if an object is present in the room? (i suppose a variable checking should do it)

EDIT: i have this for movement:
// up key
if (keyboard_check_direct(vk_up))
{
y -= 4 +(superSpeed)
sprite_index =spr_player_walk_up
Bdirection=90
}
// down key    
if (keyboard_check_direct(vk_down))
{
y += 4 +(superSpeed)
sprite_index =spr_player_walk_down
Bdirection=270
}
// left key
if (keyboard_check_direct(vk_left))
{
x -= 4 +(superSpeed)
sprite_index =spr_player_walk_left
Bdirection=180
}     
// right key
if (keyboard_check_direct(vk_right))
{
x += 4 +(superSpeed)
sprite_index =spr_player_walk_right
Bdirection=0
}

and this for the speeding up the player:
if instance_exists(obj_fly_drone) {
superSpeed+=1 }

This is all in step event. but when i move my player, the player moves at high speed! (and the distance he crosses while moving is getting bigger and bigger). And superSpeed is set at 1.

3. is there a way to create room transition of an object? (i have an object which you get from an enemy. and that object is constantly following the player through all rooms until you find a different one)

EDIT FOR 3: I used persisent option for the object but the object is away from the player in the next room (and when you find the object, the object follows you)

Edited by GreenhornGames, 17 April 2012 - 02:01 PM.

  • 0

#2 Xardov

Xardov

    Game Developer

  • GMC Member
  • 292 posts
  • Version:GM8

Posted 17 April 2012 - 02:41 PM

I assume this code is in the step event?  

if instance_exists(obj_fly_drone) {
superSpeed+=1 }

If so, then your object is moving too fast because you are increasing superSpeed by 1 every frame.  That means in 20 frames (a very short amount of time) your superSpeed is already 20.  You can just do

if instance_exists(obj_fly_drone)
{
superSpeed = 1;
}

  • 1

#3 GreenhornGames

GreenhornGames

    GMC Member

  • GMC Member
  • 730 posts
  • Version:GM8

Posted 17 April 2012 - 03:15 PM

will it decrease the player speed after the object is not in the room anymore?

after i destroyed the object that gave the player more speed, the speed didnt decrease. and i want the player to have that speed only if the object is in the room. so every destruction of that object should also take away the speed from player which was given to him.

Edited by GreenhornGames, 17 April 2012 - 03:22 PM.

  • 0

#4 shadow382

shadow382

    Shadow Studios

  • GMC Member
  • 151 posts
  • Version:Mac

Posted 17 April 2012 - 03:22 PM

will it decrease the player speed after the object is not in the room anymore?

For this, you could edit the above code to the following.

if instance_exists(obj_fly_drone)
{
superSpeed = 1;
}
else
{
superSpeed = 0;
}

I believe this is what you are asking for. If not, ignore my post.

Edited by shadow382, 17 April 2012 - 03:26 PM.

  • 1

#5 GreenhornGames

GreenhornGames

    GMC Member

  • GMC Member
  • 730 posts
  • Version:GM8

Posted 17 April 2012 - 03:29 PM

yes that works great, thanks

ok, now i need to do the following:

i have an object which is following the player. the players speed is 4 by default so i have set the following object's speed the same. but the following object can't keep up with player when the player has bigger speed:

// up key
if (keyboard_check_direct(vk_up))
{
y -= 4 +(superSpeed)
sprite_index =spr_player_walk_up
Bdirection=90
}
// down key    
if (keyboard_check_direct(vk_down))
{
y += 4 +(superSpeed)
sprite_index =spr_player_walk_down
Bdirection=270
}
// left key
if (keyboard_check_direct(vk_left))
{
x -= 4 +(superSpeed)
sprite_index =spr_player_walk_left
Bdirection=180
}     
// right key
if (keyboard_check_direct(vk_right))
{
x += 4 +(superSpeed)
sprite_index =spr_player_walk_right
Bdirection=0
}

but for the following object i have this:

Create Event:
execute code:

follow_speed=2 
follow_range=160
target_distance=0


 Step Event:
create a small effect of type flare at (x,y) of  color 65535 below objects
execute code:

target_distance = distance_to_object(obj_player);

if target_distance is smaller than follow_range
      perform a step towards position (obj_player.x-55,obj_player.y-55) with speed 4 avoiding solid only


EDIT: ok got it working :)

Edited by GreenhornGames, 17 April 2012 - 03:33 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users