Sidescroller + Jump

by Zohan98
A simple library
ID:1239588
 
A simple side-scroller i managed within about 15 ~ 25 minutes a loooong time ago. It's pretty straight forward. The jump is slightly glitched, it needs to be tweaked, I look forward to updating it in the near future.

Movement = Arrow Keys
Jump = Space_bar

Update
Special thanks to Zecronious for tweaking up the src!

If the link doesn't work besure to try...
http://www.filedropper.com/sidescroller
Fix your download link.
The end result of what you wrote is pretty cool but the source code could've been a lot better I think. There's lots of redundant code, inconsistent spacing, poor understanding and general lack of organization. Result I'd give 9/10 for accomplishing what you set out to make but code right now is like 2/10. (Being generous with 2/10 I think).

I don't even know where to begin on how bad this code is. No offense, but I'm just taking it for how it's written, nothing more.

-----

What were you even thinking.

Constant_Gravity(src);


Constant_Gravity(src)

------

This code:
mob
step_size = 32
Login()
var
size = winget(src, "map", "size")
pos = findtext(size, "x")
src.client.view = "[round(text2num(copytext(size, 1, pos)) / 32, 1)]x[round(text2num(copytext(size, pos + 1)) / 32, 1)]"
src.loc = locate(13,15,1);
src.dir = EAST
Constant_Gravity(src);

Is the same as this code:

mob
step_size = 32
Login()
var
size = winget(src, "map", "size")
pos = findtext(size, "x")
client.view = "[round(text2num(copytext(size, 1, pos)) / 32, 1)]x[round(text2num(copytext(size, pos + 1)) / 32, 1)]"
loc = locate(13,15,1)
dir = EAST
Constant_Gravity(src)

------

This line is really lazy and inefficient.
mob/Stat(){if(!moving) icon_state = "still"} //If the src isn't moving, provide the icon_state.


Delete it and put it where it's meant to be (same result):
    Move()

icon_state = "moving"
moving ++
..();
moving --
icon_state = "still"

------

The default step size is the same as the world.icon_size
The default icon_size is 32x32.
Both of these lines don't need to be there. Just delete them.

World
icon_size = 32 // 32x32 icon size by default
mob
step_size = 32

------

Since when does anyone tab variables?
        var
size = winget(src, "map", "size")
pos = findtext(size, "x")

var
size = winget(src, "map", "size")
pos = findtext(size, "x")

------

Are you serious? Either use capital letters or don't. Don't do both, that's really ugly code. Also, use full stops or don't, just don't use both. Again that's really ugly and inconsistent.
//create an object
//Gravity action, pull the player to the ground if jumping or jumping off an obj.


------

Whoever taught you do write this should get punched in the face.

    y += 1


    y++ // THE SAME THING

------

Oh dear god your functions. All your functions accept a mob/user input. Basically what you're saying by that is that they'll only ever be used by mobs. Well then why the hell are they defined as global? Did you not understand what object orientated means?

Delete all your functions and replace them with this (it's the same thing but less stoopid).

mob
step_size = 32
Login()
var
size = winget(src, "map", "size")
pos = findtext(size, "x")
client.view = "[round(text2num(copytext(size, 1, pos)) / 32, 1)]x[round(text2num(copytext(size, pos + 1)) / 32, 1)]"
loc = locate(13,15,1);
dir = EAST
Constant_Gravity(src);

Move()

icon_state = "moving"
moving ++
..();
moving --
icon_state = "still"

proc
Constant_Gravity()
//If he's kicking. (Exclamation marks are annoying not funny and not professional) Same with similys.
while(src)

//Delay
sleep(0.5)

//Gravity action, pull the player to the ground if jumping or jumping off an obj
Pull()

//Since we dont allow north or south, make sure it maintains its dir whether east or west
Maintain_Direction()

Maintain_Direction()
switch(alt_dir)
if(EAST)
dir = EAST
if(WEST)
dir = WEST
Pull()
if(jumping && !onland) return 0;

//create an object
var/obj/a = new()

//Give it some density
a.density = TRUE

//Place it the same pos of the src
a.loc = src.loc

//If the object can step down, than the he can be pulled down
if(step(a, SOUTH))
onland = null;
y -= 1
del a
return 1;
else
onland = TRUE;
verbs += /mob/can_jump/verb/jump
del a
return 0;
Jump()
verbs -= /mob/can_jump/verb/jump


jumping = TRUE
onland = null

flick("about2jump",src)

//Simple y increments

y += 1
Maintain_Direction()
sleep(0.8)

y += 1
Maintain_Direction()
sleep(0.8)

y += 1
Maintain_Direction()
sleep(0.8)

y += 1
Maintain_Direction()
sleep(0.8)
src.jumping = null;

y += 1
Maintain_Direction()
Please look at my redo of yours.

https://dl.dropboxusercontent.com/u/17647296/ Side%20Scroller.zip

Either just use this or fix yours up please, right now it's really bad.
The src is quite old... Never knew it was that bad.... I'll go ahead and apply your fixes.
Thanks for your C&C's!
No problem :/
So has this been updated? I'm thinking about checking it out. One of my biggest pet peeves though is trying to read something I had to sit and "try" to make sense of (unless I'm studying something new)
In response to Dariuc
Yeah should be better now.