Problem: when resizing the sprite it would exit the room through the boundary wall. or get stuck in a wall.
Solution: Make 4 different boundary walls.
Example:Information about object: obj_Rwall //note the R Sprite: spr_wall Solid: true Visible: true Depth: 0 Persistent: false Parent: <no parent> Mask: <same as sprite> Collision Event with object obj_player: for all obj_player: execute code: move_outside_solid(180, 20) ^ ^ // Degrees amount
Now, game maker is a little wonky when it comes to the direction, it uses degrees and 0 is right, 90 is up, 180 is left, and 270 is down, but it worksNote, it needs some fine tuning, probably a size variable but the main problem is solved.
Note, the corners can NOT be solid, they must remain as a pass through item to work right.
I came up with the rather odd idea on a basic maze game where the sprite changes size depending on what it eats, the object of the game is to get through the maze before getting stuck. Currently I am in the collision testing mode. There are temporary bubbles as the sprites, with the clown resources, wall, and background.
I cleanded up the code I had before, now I have switched to coded movement via the step instance, here is the code within the step.
{
if (keyboard_check(vk_left)) x -= 4 ;
if (keyboard_check(vk_right)) x += 4 ;
if (keyboard_check(vk_up)) y -= 4 ;
if (keyboard_check(vk_down)) y += 4 ;
view_hborder=view_wview/2 -obj_player.sprite_width; //This is to ensure the border and growth bubble plays nice
view_vborder=view_hview/2 -obj_player.sprite_height;
}This works beautifullyNow, the problem is this, if the sprite changes image size while against the wall it gets stuck there, unable to move. I could solve this by jump to a spot, but I wanted to be a little more clever. Instead I would like to have the player bounce off the wall a short distance and stop, even when a key is pressed, (and eventually a noise) I tried bounce against solid objects inside the step but it hasn't done anything.
Can someone please help me? please remember that I only have the very basics of coding and require an example of its use in simple (if possible) terms.
Breaking down the problem
Currently using Khelder's move out of solid code here
1: Player grows into the left wall
2: Player is pushed out of wall
3: Size increaser (currently bouncing around room) hits player while still in wall
4: Player grows and touches another left wall brick
5: Both bricks now push against the player, gets confused.
6: Player starts to slide down.
7: Player then slides through the bottom wall
8: Player exits room in undesired way
Possible fix:
1: Player grows into the left wall
2: Player is pushed out of wall to the right
3: Size increaser hits player while still in wall
4: Because this is the left wall the new brick pushes player to the right, popping it back into room.
5: Problem is solved.
========================
Current player info (I wish we had those dynamic collapsing containers to make it easy to browse the forum)
Information about object: obj_player
Sprite: spr_bubble
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
execute code:
script_execute (globals)
script_execute (stay_room)
play sound snd_music; looping: true
set Alarm 0 to 50
set Alarm 1 to 100
set Alarm 3 to 150
set Alarm 4 to 600
Alarm Event for alarm 3:
create instance of object obj_inflate at position (100,100)
set Alarm 3 to 100
Alarm Event for alarm 4:
if number of objects obj_big is Smaller than 1
create instance of object obj_big at position (50,50)
set Alarm 4 relative to 500
else
set Alarm 4 to 500
Step Event:
execute code:
//movement, In my opinion easier to manage than using key events
{
if (keyboard_check(vk_left)) x -= 4 ;
if (keyboard_check(vk_right)) x += 4 ;
if (keyboard_check(vk_up)) y -= 4 ;
if (keyboard_check(vk_down)) y += 4 ;
}
bounce not precisely against solid objects
End Step Event:
execute code:
view_xview[0] = (obj_player.x )-(view_wview[0]/2);
view_yview[0] = (obj_player.y )-(view_hview[0]/2);
execute code:
//I have been trying to find the best place for this code
if !place_free(x, y) {
var xold, yold, dir, len;
xold = x;
yold = y;
for (len = 2; len < 10; len += 1) {
for (dir = 90; dir < 360; dir += 45) {
move_outside_solid(dir, len);
if !(x == xold && y == yold) {
len = 20;
dir = 360;
}
}
}
}
Collision Event with object obj_wall:
for all obj_player: execute code:
script_execute (collide)
/* commented out for further testing
if bsize > (2000)
{
room_goto_next();
}
else
{
}*.
Collision Event with object obj_inflate:
play sound snd_bloow; looping: false
execute code:
script_execute (gr_check) //actually this one is currently empty
image_yscale += 10/100;
image_xscale += 10/100;
bsize += 10;
set the score relative to 1
jump relative to position (0,0)
execute code:
//this is to keep the bourder around the player
view_hborder=view_wview/2 -obj_player.sprite_width;
view_vborder=view_hview/2 -obj_player.sprite_height;
Collision Event with object obj_big:
play sound snd_inflate; looping: false
execute code:
script_execute (gr_check) //inactive
image_yscale += s1/100; //takes into account other collisions and changes size of player accordingly
image_xscale += s1/100;
set the score relative to s1
for all obj_player: set Alarm 4 relative to 1000
execute code:
view_hborder=view_wview/2 -obj_player.sprite_width;
view_vborder=view_hview/2 -obj_player.sprite_height;
Other Event: Outside Room:
play sound snd_pop; looping: false
display message: Undesirable exit
restart the current room with transition effect Fade out and in
Edited by Sonicia, 20 August 2010 - 04:57 PM.











