tell me what you think! :) -- ctrl + h to do advanced find and replace, replace ">> " with a tab.
var
>> gravity = 3 // strength of the gravity
>> jumping = FALSE // are you jumping?
>> jump_height = 0 // how much you've jumped
>> jump_height_max = 3 // how high you can jump
mob/Move(na, d)// loc, direction
>> if(d == 1 && !Applicable(SOUTH))Jump() // if pressing up and there is nothing above you you can jump!
>> else if(d == 2 || d == 6 || d == 5 || d == 9 || d == 10)return // no pressing down or diagonals ;)
>> else if(d != 1)..() // allows you to move left and right, makes sure sure can't move up(we save up for jumping ;))
mob/proc/Jump() // This function allows the player to simulate jumping
>> jumping = TRUE // states that you are now jumping
>> if(!Applicable(NORTH) || jump_height >= jump_height_max) // if there is something dense above you or you've jumped as igh as you can
>> >> jump_height = 0 // resets how high you've jumped
>> >> jumping = FALSE // says that you're no longer jumping
>> >> return // stops you from jumping
>> else y++ // makes you go up!
>> jump_height++ // keeping track of how high you've jumped
>> spawn(gravity)Jump() // the speed in which you jump is determined by the gravity
mob/proc/Gravitational_Pull() // the thing that pulls you down!
>> if(Applicable(SOUTH) && !jumping)y-- // if there is nothing below you and you're not jumping, you will be pulled down(y--)!
>> spawn(gravity)Gravitational_Pull() // the rate(speed) in which you fall depends on gravity.
atom/movable/proc/Applicable(direction) // returns true if there are no dense atoms(not including null spaces) in the direction defined, returns false otherwise
>> var/turf/t = get_step(src, direction) // sets t as the turf in the direction defined from the player
>> if(!t)return FALSE // if there is no turf there the function will return false
>> if(!t.density == 1)return FALSE // if the turf below the player is dense the function will return false.
>> for(var/atom/movable/a in get_step(src, direction))if(a.density == 1)return FALSE // if there are any dense mobs or objs in that space the function will return false
>> return TRUE // if there is no dense objs in t, this function will return true. :)
client/New() // when a new player joins this is called.
>> ..() // we want to make sure the player is actually in first.
>> spawn(gravity)mob.Gravitational_Pull() // if we didn't have this people could fly! This initializes the gravitational pull.
ID:5421
![]() Nov 15 2005, 12:54 am (Edited on Jan 4 2006, 7:41 pm)
|
|
Nice looking code, not very messy. But, for some reasion, I can't get it to work with my game. I can move freely.
Oh, wait! Nevermind, testing it, the thing wasn't set to be included. It works, but I can go through the ground, what's wrong? ~Madjarjarbinks on a new key~ |
Woops, I forgot to make it check if the turf below was dense or not. It should be fixed now. ;)
|
Zaltron, does jumping work? Now jumping doesn't work with my game with your gravity system at all, your gravity system should work great, but I think there might be something forgotten, like a var.
|
um... it still goes through my ground... how do i fix that?
|
Nice code. Way more efficiant than my gravity.