• 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!

Moving objects at same hspeed

C

Chatterb0x

Guest
Hey gang,
My game is composed of three background objects: rocks, trees, and blossoms. The blossoms are separate objects because enemy blood splatters against it. Initially, the player object moved across the level. Now I've given the background objects a global hspeed to give the illusion of movement. There is just one problem.

The objects don't move in sync! Notice the blossoms in this gif.
http://giphy.com/gifs/blind-samurai-hspeed-3o7TKN1QOUUy94jkvC

The blossom object moves 'off' the branches.
I've put plenty work into wrapping objects (thanks again GM community) but am considering Plan A.

Information about object: obj_blossom5
Sprite: spr_blossom5
Solid: false
Visible: true
Depth: -2
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

///Setting image_alpha
image_alpha = 0;
//Creating the surface
surface = surface_create(sprite_width, sprite_height)

Begin Step Event:
execute code:

hspeed = global_speed;
move_wrap(true, false, 0);

if(game_start){
surface_set_target(surface);
draw_clear_alpha(0,0);
draw_sprite(spr_blossom5,image_index,0,0);
surface_reset_target();
}

Other Event: Game End:
execute code:

///Prevent memory leak.
surface_free(surface);

Draw Event:
execute code:

///Draw surface
if(game_start == 1){
image_alpha += .05;
draw_surface(surface,x,y)
}
 

TheouAegis

Member
Instead of using the built-in move wrap, why don't you just create your own? Because maybe there's an issue with how the builtin function is handling the wrapping which you would easily be able to correct with your own wrapping code.
 
C

Chatterb0x

Guest
Instead of using the built-in move wrap, why don't you just create your own? Because maybe there's an issue with how the builtin function is handling the wrapping which you would easily be able to correct with your own wrapping code.
I'm pretty resourceful but admittedly would not know where to start.
 

TheouAegis

Member
It's as easy as
Code:
if hspeed < 0 && bbox_right < 0  x = room_width + (x - bbox_left)
else if hspeed > 0 && bbox_left > room_width  x = x - bbox_right;
put in the End Step event. You can modify things a bit if needed, but it's a pretty basic concept.
 
C

Chatterb0x

Guest
@TheouAegis
No dice. The problem isn't the wrapping, however. It may be difficult to tell from that gif but the room is 3000 px wide. The sprite moves off kilter before wrapping.
 

TheouAegis

Member
BEFORE wrapping? That's odd. No solid collisions anywhere with the blossoms, right? Do you even have any solids? I never had issues until after wrapping, personally (which is why I coded my own wrapping codes).
 
C

Chatterb0x

Guest
Zero solid objects (unless checked by mistake). The only collision that occurs is between the blood and blossom object.
 
C

Chatterb0x

Guest
Ahaha...
I may have solved the problem. The tree and blossom were Begin and Step events, respectively. Though they shared an hspeed, it was set at slightly different times.
 
Top