Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411651 Posts in 69395 Topics- by 58451 Members - Latest Member: Monkey Nuts

May 15, 2024, 11:16:18 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Problems with wall objects in a JnR game
Pages: [1]
Print
Author Topic: Problems with wall objects in a JnR game  (Read 1244 times)
AriesT
Level 0
**



View Profile WWW
« on: May 15, 2010, 02:29:00 AM »

Hello dear Game Maker pros,
I bought Game Maker 8 recently and now I'm figuring out how to create Jump n Run game elements. With big help by Alex May, I could set gravity and the controls for a simple square in a small room. I use it like my test room before making a real stage.

Now I have some trouble to shoot for the wall objects, which consist of a simple vertical sprite.



1. When I'm jumping on a free wall element, like you see it in the picture, the square gets stuck. - I guess this has something to do with the gravity but I'm not sure.
2. When I jump next to a wall and holding the arrow key for walking towards it, the square can do kind of a double jump which is not to be intended.
3. The square always stops like 1 or 2 pixels away from the wall and does not touch it directly.

If it helps, here is the STEP events code:
Code:
// Gravity 
// check if in air, step event
if(place_free(x,y+1))
{
    gravity = 0.3; // turn on the gravity
}

if (vspeed >= 12)
{
    vspeed = 12;
}


 // Controls
  
 if (keyboard_check(vk_left))
 {
     x -= 5;
 }
 else if (keyboard_check(vk_right))
 {
     x += 5;
 }
  
if (keyboard_check_pressed(vk_space) and !place_free(x,y+1))
{
    vspeed = -8;
}

and the code when colliding with the wall object:
Code:
x += 0;

I hope you pros can help me a bit. I'd appreciate that. Smiley

Cheers,
Aries
« Last Edit: May 15, 2010, 08:09:04 AM by AriesT » Logged

Never give up your dreams. They are worth to live for!
AriesT
Level 0
**



View Profile WWW
« Reply #1 on: May 17, 2010, 06:09:43 AM »

Maybe the gmk file helps a lot:

*Click me, I'm jnr.gmk*
Logged

Never give up your dreams. They are worth to live for!
nikki
Level 10
*****


View Profile
« Reply #2 on: May 17, 2010, 06:42:31 AM »

not too sure about GM but whats the point of this ? :
Quote
x += 0;
Logged
Wizard
Level 0
**


metagalactic llama wizard


View Profile WWW
« Reply #3 on: May 17, 2010, 07:48:03 AM »

Try this code for size - you are really close to having it cracked but there were a few minor bugs and comments i'd like to make:

1 > You should always put jump before direction, or you get a nasty bug that makes you run off the edge of platforms, and it isn't pretty.
2 > Your wall objects should be solid, or it causes collision bugs.
3 > Your code is looking pretty solid, good work :D

Code:
if place_free(x,y+1) // is there something below me?
{
    gravity = 0.3; // if there's nothing below, gravity on
}else{
    gravity = 0; // if there is something below, gravity off
}

if (vspeed >= 12) // if we're going too fast
{
    vspeed = 12; // let's not go so fast
}

if (keyboard_check_pressed(vk_space) and !place_free(x,y-8))
{
    vspeed = -8;
}

if (keyboard_check(vk_left) and place_free(x-5,y)) // keyboard left, check if there's anything in the way first
{
    x -= 5;
}
else if (keyboard_check(vk_right) and place_free(x+5,y))  // keyboard right, check if there's anything in the way first
{
    x += 5;
}

And for colliding with walls:-
Code:
y=ceil(y); // makes sure your y co-ord is an integer
move_contact_all(direction,12); // moves the player so it's actually touching the ground
speed = 0; // kills all speed
Logged

Shit, we're up against a Sysadmin...
The Wizard's Lair | my Sketchbookr | Ask me anything!
AriesT
Level 0
**



View Profile WWW
« Reply #4 on: May 17, 2010, 10:22:03 AM »

Thank you for the quick help.

Now my figure does not jump anymore, when I'm adding your code. If I remove the "!place_free(x,y-8)" part from the jump command, it works but has some flaws touching the wall and the !-boxes (it kind of flickers and does not move straight through it).
I'd like you to have a look at the _real_ gmk (I know I put the .exe in the rar file... Roll Eyes )

Maybe you can kill this last bug.

Now I'm a .gmk file!
Logged

Never give up your dreams. They are worth to live for!
Wizard
Level 0
**


metagalactic llama wizard


View Profile WWW
« Reply #5 on: May 17, 2010, 10:43:37 AM »

Here's a fixed GMK file with a couple tweaks - Your buttons shouldn't be solid or your character won't collide with them properly.

You also don't need to have separate collision events for solid objects, create a solid object then set o_floor_PARENT as it's parent, and the rest is done automagically.

I fixed the jump problem, a big typo by me, sorry!

Download :
http://www.wizardslair.co.uk/dev/jnr.gmk
Logged

Shit, we're up against a Sysadmin...
The Wizard's Lair | my Sketchbookr | Ask me anything!
AriesT
Level 0
**



View Profile WWW
« Reply #6 on: May 17, 2010, 10:58:58 AM »

It works!
Thanks a lot. Now I can do further research. Wink
E.G. only activating triggers when dodging the buttons from below (like in a Mario game).

Would it bother you if I could be your little padavan as long as I'm learning GM8 and coding basics in general?
« Last Edit: May 17, 2010, 11:02:52 AM by AriesT » Logged

Never give up your dreams. They are worth to live for!
Wizard
Level 0
**


metagalactic llama wizard


View Profile WWW
« Reply #7 on: May 17, 2010, 11:19:07 AM »

Yeah, sure why not. Add me on MSN(look in my profile) and i'll help where I can.
Logged

Shit, we're up against a Sysadmin...
The Wizard's Lair | my Sketchbookr | Ask me anything!
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic