PDA

View Full Version : Yuss finally.

ianCSzz
09-12-2015, 03:01 AM
I've finally wrote a code to make a player move! Now all I need to do is...

*looks at my game ideas*

okay never mind.

MyLegGuy
09-12-2015, 03:36 AM
Cool. What programming language?

ianCSzz
09-12-2015, 03:39 AM
Cool. What programming language?
ActionScript 2.0, on Macromedia Flash 8. 'cuz it's the one that I know the most.

|ThyLuigi|
09-12-2015, 03:46 AM
Paste the source code, I wanna see how long it is

ianCSzz
09-12-2015, 03:50 AM
Paste the source code, I wanna see how long it is
It's not really that long, but I tried to figure this out myself.

var gravity = 0;
var jumpHeight = 15;
var speed = 10;
var jumping = false;
var fall = false;
var walk = false;

_root.onEnterFrame = function(){
player._y += gravity;
if(player._y+player._height < ground._y){
gravity++;
fall = true;
};
if(player._y+player._height >= ground._y){
gravity=0;
player._y = ground._y-player._height;
fall = false;
player.gotoAndStop("stand");
jumping = false;
};
if(Key.isDown(Key.UP)){
if(fall == false){
gravity = -jumpHeight+1;
player.gotoAndStop("jump");
jumping = true;
};
};
if(Key.isDown(Key.LEFT)){
if(ground._x<0 && player._x<Stage.width/2){
ground._x += speed;
} else if(ground._x==0 && player._x>0){
player._x -= speed;
} else if(player._x>Stage.width/2){
player._x -= speed;
};
if(jumping == false){
player.gotoAndStop("walk");
};
};
if(Key.isDown(Key.RIGHT)){

if(ground._x+ground._width>Stage.width && player._x>Stage.width/2){
ground._x -= speed;
} else if(ground._x+ground._width==Stage.width && player._x+player._width<=Stage.width){
player._x += speed;
} else if(player._x<Stage.width/2){
player._x += speed;
};
if(jumping == false){
player.gotoAndStop("walk");
};
};
};

MyLegGuy
09-12-2015, 04:06 AM
It's not really that long, but I tried to figure this out myself.

var gravity = 0;
var jumpHeight = 15;
var speed = 10;
var jumping = false;
var fall = false;
var walk = false;

_root.onEnterFrame = function(){
player._y += gravity;
if(player._y+player._height < ground._y){
gravity++;
fall = true;
};
if(player._y+player._height >= ground._y){
gravity=0;
player._y = ground._y-player._height;
fall = false;
player.gotoAndStop("stand");
jumping = false;
};
if(Key.isDown(Key.UP)){
if(fall == false){
gravity = -jumpHeight+1;
player.gotoAndStop("jump");
jumping = true;
};
};
if(Key.isDown(Key.LEFT)){
if(ground._x<0 && player._x<Stage.width/2){
ground._x += speed;
} else if(ground._x==0 && player._x>0){
player._x -= speed;
} else if(player._x>Stage.width/2){
player._x -= speed;
};
if(jumping == false){
player.gotoAndStop("walk");
};
};
if(Key.isDown(Key.RIGHT)){

if(ground._x+ground._width>Stage.width && player._x>Stage.width/2){
ground._x -= speed;
} else if(ground._x+ground._width==Stage.width && player._x+player._width<=Stage.width){
player._x += speed;
} else if(player._x<Stage.width/2){
player._x += speed;
};
if(jumping == false){
player.gotoAndStop("walk");
};
};
};

Nice! This is for a 2d platformer, I'm assuming? You still need collision detection though.

|ThyLuigi|
09-12-2015, 04:11 AM
Does it allow you to move while jumping?

ianCSzz
09-12-2015, 04:14 AM
Nice! This is for a 2d platformer, I'm assuming? You still need collision detection though.
Ye, it's 2D platformer. It's also going to be some... I don't know, RPG stuff? I am working on the collision detection.

- - - Updated - - -

Does it allow you to move while jumping?
Yes it does. I'm making it like Growtopia.

GummiBear64
09-12-2015, 04:50 AM
I am currently making my own game in my IT class.
It's for a SAC so it isn't free choice however it requires a LOT of code.
We had to pretend we were making it for prep students and it was to help them learn the capital letters of the alphabet.
So, it would have "type the letter >random letter generated here< in capitals > " and then it would check to see if it was correct.