• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Vacuum Effect?

Y

Yoazze

Guest
I am currently in the process of making an rpg dungeon crawling type game (similar to games like that of the Diablo series). Im currently having a hard time with the experience system I want for my game. What i would like to do is try to make it so that when the player kills an enemy, the enemy drops experience "globes" scattered around where the enemy was slain and the player holds down a key to create somewhat of a vacuum effect and sucks up all the scattered globes the enemy had dropped after dying. The system im trying to use was inspired by the Fable games. I think its a unique and fun idea and i think the player would get a good amount of satisfaction seeing all those tasty experience globes get sucked up after slaying the countless number of enemies in the players path. I have tried finding information about this numerous times and have yet to find anything about it or anything similar. So I wanted to try asking here to see if anyone has an idea of how something like this could work and share it. Any and all help would be greatly appreciated
 
What have you tried so far? Any code you can show us? Let's think about this logically, step by step! You need to:

-push items toward the player when the button is held. Have you done this yet? If not, can you figure this part out yourself?

-probably want to push "harder" (further) when objects are closer to the player. Gravity has falloff, right?

-add to the objects' speed each frame, so they accelerate? They'll "accelerate" just by getting closer to the player though, so maybe unnecessary, even if it's realistic.

Go through and work each thing out one at a time. Big scary problems are just multiple small problems smushed together. ;D
 
Last edited:
W

whale_cancer

Guest
Pseudo logic is simple. While holding down the 'vacuum' button, iterate through all the experience orbs and have them move towards the player. Destroy the orbs and add the XP when they collide with the player.
 
Y

Yoazze

Guest
Unfortunately I haven't implementing any code towards it yet. Im still fairly new to gamemaker and im not "fluent" so to speak with GML. So im looking for someone who could tell me the code id need to put or at least somewhat of a place I can start from
 
Y

Yoazze

Guest
What have you tried so far? Any code you can show us? Let's think about this logically, step by step! You need to:

-push items toward the player when the button is held. Have you done this yet? If not, can you figure this part out yourself?

-probably want to push "harder" (further) when objects are closer to the player. Gravity has falloff, right?

-add to the objects' speed each frame, so they accelerate? They'll "accelerate" just by getting closer to the player though, so maybe unnecessary, even if it's realistic.

Go through and work each thing out one at a time. Big scary problems are just multiple small problems smushed together. ;D
This is exactly what I would want to happen but sadly I dont even know where to begin to make something like that work :,(
 

TheouAegis

Member
Step event of pickup object:

Code:
if global.vacuum
{
    var d = point_distance(x,y,obj_player.x, obj_player.y);
    if d < 256
    move_towards_point(obj_player.x, obj_player.y, 64/sqr(d>>4))
}
else speed=0;
in the player object, set glboal.vacuum to true when the player holds the suck key, otherwise set it to false.
 
Y

Yoazze

Guest
Step event of pickup object:

Code:
if global.vacuum
{
    var d = point_distance(x,y,obj_player.x, obj_player.y);
    if d < 256
    move_towards_point(obj_player.x, obj_player.y, 64/sqr(d>>4))
}
else speed=0;
in the player object, set glboal.vacuum to true when the player holds the suck key, otherwise set it to false.
Awesome thank you much. Unfortunately I get all my input from a persistent object i have in the room which calls a script I have that holds the input keys which i think is causing it not to work. I tried calling the vacuum key from the instance object but nothing happens when i press the key. I get no error messages or anything its just the object doesnt move. Also im using physics so idk if that has something to do with it as well
 

TheouAegis

Member
You can do it with physics but you'd need to change some things.

Not sure if you can use point_distance anymore, but if you can, you'd change x and y to phy_position_x and phy_position_y respectively.
For setting the motion, you'd need to I think apply an impulse. I don't use the physics engine, so I myself am not sure what changes you'd need to make.
 
Top