Jump to content


Very Melon

Member Since 12 Oct 2007
Offline Last Active Feb 23 2012 09:46 PM

Topics I've Started

Jumping And Gravity Script Check

21 March 2010 - 01:51 PM

Hey how are you doing?

I'm currently working on a new platforming game and there's something wrong with my jumping and gravity script.

//scr_ACTIONS script:
//Imagespeed and Gravity setup
//Walking and Running
//Attacking
//Jumping
//Crouching

//Imagespeeds
standspeed = argument0
walkspeed = argument1
runspeed = argument2
attackspeed = argument3
kickspeed = argument4

//Gravity
if place_free(x,y+1)
{
gravity = 0.65
gravity_direction = 270
}
else
{gravity = 0}

if vspeed > 10
{vspeed = 10}


if hit = 2 //if taking damage
{exit}
else
{

-
-

//JUMPING
if place_free(x,y+1)
{
if sprite_index = Pjumps || sprite_index = Pjumpm || sprite_index = Pfall || sprite_index = Pattack || sprite_index = Pairkick
{
sprite_index = sprite_index
exit
}
if (sprite_index != Pjumps || sprite_index != Pjumpm || sprite_index != Pfall || sprite_index != Pattack || sprite_index != Pairkick)
{

if jumpPressed = 0
{
sprite_index = Pfall
image_speed = 0.5
if image_index > 0 && image_index != 1
{image_index = 1}
}
if jumpPressed = 1
{
if sprite_index = Pjumps || sprite_index = Pjumpm
{
if vspeed < -1
{if image_index > 0
{image_index = 0}
}
if (vspeed > -1 && vspeed < 0)
{if image_index > 2
{image_index = 2}
}
if vspeed > 0
{if image_index >= 4
{image_index = 4}
}
}
}
}

if place_free(x,y+1) && (sprite_index != Pjumps || sprite_index != Pjumpm || sprite_index != Pfall || sprite_index != Pattack || sprite_index != Pairkick)
{if vspeed < 0
{sprite_index = Pjumpm}
if vspeed >= 0
{sprite_index = Pfall}
}

}

if keyboard_check_pressed(b_jump)
{
if (!place_free(x,y+1)) 
{if sprite_index = Pattack
{exit}
if sprite_index = Pstand
{
vspeed = -8
sprite_index = Pjumps
jumpPressed = 1
image_xscale = image_xscale
}
if sprite_index = Pwalk || sprite_index = Prun
{
vspeed = -8
sprite_index = Pjumpm
jumpPressed = 1
image_xscale = image_xscale
}
}
}

if keyboard_check_released(b_jump)
{
if vspeed < 0
{
vspeed /= 1.75
}
}

if !place_free(x,y+1)
{
if sprite_index = Pjumps || sprite_index = Pjumpm || sprite_index = Pfall ||sprite_index = Pairkick
{
if !keyboard_check_pressed(b_left) || !keyboard_check_pressed(b_right)
{
sprite_index = Pstand
image_speed = standspeed
hspeed = 0
jumpPressed = 0
if canAttack = 0
{canAttack = 1}
}
else
{
if runPressed = 0
{
sprite_index = Pwalk
image_speed = walkspeed
if canAttack = 0
{canAttack = 1}
}
if runPressed = 1
{
sprite_index = Prun
image_speed = runspeed
if canAttack = 0
{canAttack = 1}
}
}
}

}

-

}

This is my script with only gravity and jumping parts included. Whenever my character jumps, he jumps only for a couple of pixels and starts falling really slowly. Also the jumping sprite isn't correct; whenever jumping only the falling sprite is shown.

-Very Melon

Adding Smoothness To Your Game

03 March 2010 - 08:09 PM

Hey everybody!

I was wondering, what would be the best way to make your game smoot? I know, the simplest answer is to raise the room speed. But if you do that it makes it difficult to deal with all your variables as they are all increased along with room speed. Any clues? B-)

-Very Melon

Help With Fixed Arc

09 August 2009 - 07:35 PM

Hello everybody! It's me, Very Melon.

It's about time I brought this thing up. I've been doing some Megaman -style games for a time now and the need of  objects flying in a fixed arc is up in these kind of games.  Up to now I've been living with the system of checking a known distance and the setting the flying object's vertical and horizontal speeds, like this:

if distance_to_object(obj_target) > 120 then
{
instance_create(obj_axe,x,y)
instance_nearest(obj_axe).hspeed = blah blah
instance_nearest(obj_axe).vspeed = blah blah
}

if distance_to_object(obj_target) > 80 then
{
instance_create(obj_axe,x,y)
instance_nearest(obj_axe).hspeed = blah blah
instance_nearest(obj_axe).vspeed = blah blah
}

//And so on and on...

Well, this technique is very crappy and susceptible to bugs and flaws. :)  So I'm starting a new Megaman -project and this time I have a goal to do everything on a solid ground. So I'd like to ask:

Does anyone know a solid formula for this action? Or can give some guidelines for a solid formula?

This action has haunted me for quite some time. I've tried to search the forum many times for examples/guides without success. Help very appreciated, please reply.

-Very Melon

A Question About Loops

15 June 2009 - 04:34 PM

(Please move if this in the wrong section.)

Hey everyone, this is Very Melon writing.

I know GML quite good, but I haven't got into loops yet. Well, I've been trying to generate a little acceleration feature using loops to my Metroid-fangame, but the script I wrote freezes the game totally. I guess this is because of a little typo or something, but as I said above, I really don't understand loops yet effectively. So, please GML experts, please take look:

while (crouch = 0 && morphb = 0) = true
{

if (keyboard_check(global.leftB) || keyboard_check(global.rightB)) = true
{
switch dir
{
case 0:
for ( i = 0; i < runspeed; i += 0.5 )
{
   hspeed -= 0.5
   dir = 0
}
if hspeed < -runspeed
{
   hspeed = -runspeed
}
;break;
case 1:
for ( i = 0; i < runspeed; i += 0.5 )
{
   hspeed += 0.5
   dir = 1
}
if hspeed > runspeed
{
   hspeed = runspeed
}
;break;
}
}
}

-Very Melon

Programming Perfect Samus

14 December 2008 - 02:50 PM

Over the last few months, I've seen tens of "how do I program morph ball" or "how do I make her shoot" topics, so I figured that there should be a topic where people could post their suggestions, not only about Metroid but also about strategic platform games in general.

For example, when I've wanted to make a platform shooter where you could crouch etc, I've always used one variable to make sure in which position are you in.

~Very Melon