On-Screen Control Tutorial

Learn how to make certain types of games and use gameEditor.

On-Screen Control Tutorial

Postby Bee-Ant » Thu Feb 16, 2012 4:23 am

Hi everyone.
Since I got so many request about this stuff, so here I make it.

ON-SCREEN CONTROL FOR PLATFORMER GAME

First of all, create the needed actors:
1. ButtonLeft
2. ButtonRight
3. Button Jump
Don't forget to set those button's ZDepth to the highest value. And the transparency to be about 30% (optional)
Image
4. Platform
5. Background
6. Player
For easier animation management for the player, I named his animations with format "Name-Action-Direction" as follows:
- "PlayerStopLeft"
- "PlayerStopRight"
- "PlayerRunLeft"
- "PlayerRunRight"
- "PlayerJumpLeft"
- "PlayerJumpRight"
Image


Now, let's move to the coding step:

1. Prepare the needed variables on Global code
Code: Select all
int Action; //0: Stop, 1: Run
int Direction; //-1: Left, 0: None, 1: Right
int Jump; //0: On the ground, 1: Jumping

char PlayerAction[3][16]={"Stop","Run"};
char PlayerDirection[4][16]={"Left","None","Right"};


2. Set the Player basic code:
- Player > Collision > Any Side; Repeat: Yes > Platform:
Code: Select all
PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_CALCULATED_MASS, 1.000000, 1.000000, 0.000000, 0.000000);

- Player > Collision > Top Side; Repeat: Yes > Platform:
Code: Select all
Jump=0; //Grounding

- Player > Create Actor:
Code: Select all
//Initial value
Action=0; //Stop
Direction=1; //Facing Right

- Player > Draw Actor:
Code: Select all
char tmp[32];

yvelocity++; //gravity effect
x+=Action*Direction*5; //5 is the walking speed

if(Jump==0) //if on the ground
{
    //Get the player animation name based on it's condition (Name+Action+Direction)
    //and store it to 'tmp' variable
    sprintf(tmp,"Briver%s%s",PlayerAction[Action],PlayerDirection[Direction+1]);
    //change the animation as the stored value
    ChangeAnimation("Event Actor", tmp, NO_CHANGE);
}
if(Jump==1) //if jumping
{
    sprintf(tmp,"BriverJump%s",PlayerDirection[Direction+1]);
    ChangeAnimation("Event Actor", tmp, NO_CHANGE);
}


3. Now, setup the control. This is the key feature. While in normal control (without using on-screen key) you set the control mostly in "Player > Key Down" and "Player > Key Up"... in on-screen control, we set the player control in "Button > Mouse Click" and "Button > Mouse Down".
- ButtonLeft > Mouse Button Down > (Left Click):
Code: Select all
Action=1; //Walk
Direction=-1; //Facing Left

- ButtonLeft > Mouse Button Up > (Left Click):
Code: Select all
Action=0; //Stop

- ButtonRight > Mouse Button Down > (Left Click):
Code: Select all
Action=1; //Walk
Direction=1; //Facing Right

- ButtonRight > Mouse Button Up > (Left Click):
Code: Select all
Action=0; //Stop

- ButtonJump > Mouse Button Down > (Left Click):
Code: Select all
if(Jump==0) //if on the ground
{
    Player.yvelocity=-15;
    Jump=1; //Jump
}


That is all the basic.
You can add more tweaks you want.
Let me know if you have any question.
Good luck :D

Image

Here's the full demo: http://dl.dropbox.com/u/3997355/Demo/On ... ontrol.zip
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: On-Screen Control Tutorial

Postby Fuzzy » Thu Feb 16, 2012 7:31 am

Bee-Ant wrote:Let me know if you have any question.


Yeah, I have a few questions.

What's with your face? Why is it like that? :P :P
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: On-Screen Control Tutorial

Postby Bee-Ant » Thu Feb 16, 2012 8:30 am

Fuzzy wrote:What's with your face? Why is it like that?

What's with my face?handsome???cute???
Oh, I don't know whether this is a miracle or curse...
Please don't mention my handsomeness anymore, you made me shy :oops:
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: On-Screen Control Tutorial

Postby Fuzzy » Thu Feb 16, 2012 11:22 am

Bee-Ant wrote:
Fuzzy wrote:What's with your face? Why is it like that?

What's with my face?handsome???cute???
Oh, I don't know whether this is a miracle or curse...
Please don't mention my handsomeness anymore, you made me shy :oops:


Haha! Nice reply!
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: On-Screen Control Tutorial

Postby DST » Thu Feb 16, 2012 1:01 pm

*pukes*
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: On-Screen Control Tutorial

Postby SuperSonic » Thu Feb 16, 2012 4:35 pm

I love the sarcasm around here :P
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: On-Screen Control Tutorial

Postby Behdadsoft » Thu Oct 03, 2013 8:09 pm

can use this method for iPhone games?
There is no possible way, if we found will make a way.

http://behdadsoft.com/
*******************************************************************
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0
User avatar
Behdadsoft
 
Posts: 207
Joined: Wed Dec 16, 2009 9:19 pm
Score: 2 Give a positive score

Re: On-Screen Control Tutorial

Postby JaroodaGames » Thu Oct 03, 2013 11:35 pm

Behdadsoft wrote:can use this method for iPhone games?

Pretty sure that's what this tutorial is made for.
User avatar
JaroodaGames
 
Posts: 56
Joined: Sun Jun 09, 2013 5:57 pm
Score: 2 Give a positive score

Re: On-Screen Control Tutorial

Postby Behdadsoft » Fri Oct 04, 2013 8:26 am

Pretty sure that's what this tutorial is made for.


Thanks

+1 :D
There is no possible way, if we found will make a way.

http://behdadsoft.com/
*******************************************************************
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0
User avatar
Behdadsoft
 
Posts: 207
Joined: Wed Dec 16, 2009 9:19 pm
Score: 2 Give a positive score


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest