Game errors

Non-platform specific questions.

Game errors

Postby DeltaLeeds » Sun Jul 01, 2012 7:15 pm

Hello, I have a problem with this script. :oops:
Life= textNumber that floats on top of the player that represents his life. (I'm gonna use actor vars but I'm still a beginner)
Code: Select all
if(Life.textNumber>=90)//When life is 90 or more,the colour turns cyan/bright blue
{
    r=0;
}

if(Life.textNumber>=50)//When life is 50 or more,the colour turns Green
{
    r=0;
    b=0;
}

if(Life.textNumber>=25)//When life is 25 or more,the colour turns Yellow
{
    b=0;
}

if(Life.textNumber>=10)//When life is 10 or more,the colour turns Orange
{
    g=75;
    b=0;
}

if(Life.textNumber>=1)//When life is 1 or more,the colour turns Red
{
    g=0;
    b=0;
}

if(Life.textNumber==0)//When life is 0 ,the colour turns dark red.
{
 
    g=0;
    b=0;
    r=50;
}


When I go to game mode,the life numbers disappear for some reason. :?
Any suggestions?
Last edited by DeltaLeeds on Mon Jul 02, 2012 9:24 am, edited 1 time in total.
Currently: Semi-Active.
Working on: Maybe putting my test games in gamejolt, polishing them a bit, but I still don't know when.
User avatar
DeltaLeeds
 
Posts: 693
Joined: Fri May 06, 2011 12:45 pm
Location: In front of my computer.
Score: 38 Give a positive score

Re: Text colour help

Postby skydereign » Sun Jul 01, 2012 9:09 pm

The problem is you are setting rgb equal to 0. When you have code that isn't doing what you want, you should step through it. Assuming life starts at 100.
Code: Select all
if(Life.textNumber>=90)//When life is 90 or more,the colour turns cyan/bright blue
{
    r=0;
}

if(Life.textNumber>=50)//When life is 50 or more,the colour turns Green
{
    r=0;
    b=0;
}
// by this point rgb is already set to 0 if life is 100

if(Life.textNumber>=25)//When life is 25 or more,the colour turns Yellow
{
    b=0;
}

if(Life.textNumber>=10)//When life is 10 or more,the colour turns Orange
{
    g=75;
    b=0;
}

//at this point g is set to 75

if(Life.textNumber>=1)//When life is 1 or more,the colour turns Red
{
    g=0;
    b=0;
}
// but this sets it back to 0

if(Life.textNumber==0)//When life is 0 ,the colour turns dark red.
{

    g=0;
    b=0;
    r=50;
}

What you want to do is specify else if. Otherwise all of those if statements can be true at the same time. So, turn all if statements after the first one to else if. Also, as I've told you before, don't use textNumber like that.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

How to shoot Projectiles?

Postby DeltaLeeds » Mon Jul 02, 2012 4:32 am

It works!!!! You're awesome skydereign! Thanks :D
EDIT:Theres something wrong with the colours.When my life goes below 50 it stays green! And when it goes below 10,it becomes dark green!
EDIT2:Ah fixed xD. My colour commands were wrong! xD
EDIT3:How to make actors shoot in random directions if the projectile is called "Laser" for example?
Currently: Semi-Active.
Working on: Maybe putting my test games in gamejolt, polishing them a bit, but I still don't know when.
User avatar
DeltaLeeds
 
Posts: 693
Joined: Fri May 06, 2011 12:45 pm
Location: In front of my computer.
Score: 38 Give a positive score

Re: Game errors

Postby schnellboot » Mon Jul 02, 2012 11:00 am

something like this?
Attachments
random direction.ged
(1.03 KiB) Downloaded 100 times
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Game errors

Postby DeltaLeeds » Mon Jul 02, 2012 11:06 am

I see the script now! Thanks Schnell! xD
Currently: Semi-Active.
Working on: Maybe putting my test games in gamejolt, polishing them a bit, but I still don't know when.
User avatar
DeltaLeeds
 
Posts: 693
Joined: Fri May 06, 2011 12:45 pm
Location: In front of my computer.
Score: 38 Give a positive score

How to remove decimal

Postby DeltaLeeds » Mon Jul 02, 2012 3:56 pm

I have another question,how to remove decimals in numbers?
Currently: Semi-Active.
Working on: Maybe putting my test games in gamejolt, polishing them a bit, but I still don't know when.
User avatar
DeltaLeeds
 
Posts: 693
Joined: Fri May 06, 2011 12:45 pm
Location: In front of my computer.
Score: 38 Give a positive score

Re: Game errors

Postby schnellboot » Mon Jul 02, 2012 3:58 pm

depends on what you want:
1.
3.3 becomes 3
3.7 becomes 4
2.
3.3 becomes 3
3.7 becomes 3

what do you want?
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Game errors

Postby skydereign » Mon Jul 02, 2012 5:30 pm

If you always want to round down (just remove the floating point) you can either cast it to an int, or use floor. If you want it to always round up, you have to use ceil. But if you want to use normal rounding (.5 and up round up, anything lower round down) you have to use round.
Code: Select all
double d_var = 4.7;
d_var = (int)d_var; // this casts d_var as an int (always rounds down)
// d_var now equals 4.0

d_var = 4.7;
d_var = floor(d_var); // always rounds down
// d_var now equals 4.0

d_var = 4.7;
d_var = ceil(d_var); // always rounds up
// d_var now equals 5.0

d_var = 4.2;
d_var = round(d_var); // rounds down or up
// d_var now equals 4.0

d_var=4.7;
d_var = round(d_var); // rounds up in this case
// d_var now equals 5.0
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Game errors

Postby DeltaLeeds » Tue Jul 03, 2012 8:31 am

Thanks to everyone's support,here it is,my very first test game. Remember,this is just practice xD
Download:

Most of the bugs are fixed thanks to Bee-Ant,but report for more bugs so I can make better games ;)

Windows: https://www.dropbox.com/s/phwidfmuat58c ... indows.exe
Linux: https://www.dropbox.com/s/xehiwz8wl4xw7 ... me%20Linux
Mac: https://www.dropbox.com/s/7xod519fw0k4l ... game%20Mac

Music thanks to:VGMusic..for Boss music and Platinum Arts Sandbox... for Stage and Win music,and MrJolteon who gave me the Platinum Arts Sandbox game.

Graphics thanks to: Terraria,GE,MrJolteon (Who gave me Terraria)

Script thanks to:Skydereign,Schnellboot,Gameagogo,MrJolteon,Wertyboy.
Last edited by DeltaLeeds on Fri Jul 06, 2012 7:11 am, edited 1 time in total.
Currently: Semi-Active.
Working on: Maybe putting my test games in gamejolt, polishing them a bit, but I still don't know when.
User avatar
DeltaLeeds
 
Posts: 693
Joined: Fri May 06, 2011 12:45 pm
Location: In front of my computer.
Score: 38 Give a positive score

Re: Game errors

Postby Bee-Ant » Wed Jul 04, 2012 3:59 pm

Bugs.. errr, mistakes found :P

1. Pressing "m" didn't stop the music.
Suggested solution:
- Make a global "Real" variable called "MUSICVOL"
- view -> DrawActor -> Script Editor:
Code: Select all
musicvol=MUSICVOL;

- YourMusicControllerActor -> KeyDown -> m -> ScriptEditor:
Code: Select all
int tmp;
tmp=abs(MUSICVOL-1);
MUSICVOL=tmp;


2. The snake is somehow flying
Image
Suggested solution:
- Snake -> DrawActor -> ScriptEditor:
Code: Select all
yvelocity++;

- Snake -> Collision -> Any side of Platform -> PhysicalResponse: 1 1 0 0
*you should know this :P

3. The pink bullet is somehow created on startup.
Suggested solution:
Image

4. Even though the player is facing left, the created bullet is shot to the right
Image

Those are what I found so far.
And here let me help you fix the current mistakes...

jonathang wrote:1.When SP is 5,a or s does not make any pink slimes.

Player -> KeyDown -> s -> ScriptEditor:
Code: Select all
if(SP>=5)
{
    //CreatePinkBullet here
    SP-=5;
}


jonathang wrote:2.There is an invisible wall thats supposed to prevent us come to the boss when the enemies left is more then 1 but it doesn't seem to work.

Player -> DrawActor -> ScriptEditor:
Code: Select all
//say the LimiterWall x coordinate is 999 (change this to the actual coordinate)
if(EnemyLeft>1)
{
    x=min(x,999);
}


jonathang wrote:When the player heals and has more then 89 HP,the life doesn't become Cyan/Light Blue

HP -> DrawActor -> ScriptEditor:
Code: Select all
//insert this code in the last line
if(Player.HP>89)
{
    r=0;
    g=b=255;
}
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

A new level

Postby DeltaLeeds » Thu Jul 05, 2012 8:20 am

I need help! I'm making a new level for the game and there will be a moving cloud which moves according to a path,but I want to make the cloud move when the player steps on it. How to do that?
Currently: Semi-Active.
Working on: Maybe putting my test games in gamejolt, polishing them a bit, but I still don't know when.
User avatar
DeltaLeeds
 
Posts: 693
Joined: Fri May 06, 2011 12:45 pm
Location: In front of my computer.
Score: 38 Give a positive score

Re: A new level

Postby Wertyboy » Fri Jul 06, 2012 7:26 am

jonathang wrote:I need help! I'm making a new level for the game and there will be a moving cloud which moves according to a path,but I want to make the cloud move when the player steps on it. How to do that?

Hmm... Player - Collision (Cloud) - Script:
Code: Select all
cloud.x+=[number]; //If move right

Code: Select all
cloud.x-=[number]; //If move left

Code: Select all
cloud.y+=[number]; //If move down

Code: Select all
cloud.y-=[number]; //If move up

If you want the cloud move even the player finish collision, change x or y to xvelocity or yvelocity (but turn off the REPEAT)

EDIT: A path.... hmm
Cloud - Collision (player) - Change Path
Last edited by Wertyboy on Fri Jul 06, 2012 7:33 am, edited 1 time in total.
User avatar
Wertyboy
 
Posts: 543
Joined: Tue Jun 15, 2010 12:38 pm
Location: HCM City, Vietnam
Score: 44 Give a positive score

Re: Game errors

Postby DeltaLeeds » Fri Jul 06, 2012 7:32 am

Wertyboy wrote:
jonathang wrote:I need help! I'm making a new level for the game and there will be a moving cloud which moves according to a path,but I want to make the cloud move when the player steps on it. How to do that?

Hmm... Player - Collision (Cloud) - Script:
Code: Select all
cloud.x+=[number]; //If move right

Code: Select all
cloud.x-=[number]; //If move left

Code: Select all
cloud.y+=[number]; //If move down

Code: Select all
cloud.y-=[number]; //If move up

If you want the cloud move even the player finish collision, change x or y to xvelocity or yvelocity (but turn off the REPEAT)

EDIT: A path.... hmm
Cloud - Collision (player) - Change Path


Thanks werty! It worked :D :D :D

Now I have a problem with the rand(); command.
I want to make the damage decimals but the life stays rounded off like Skyde's instructions above about floor/ceil/round.
So I made an actor which collides to the player and reduces its life by using this command: Player.LifeVar-=rand(0.75);
Somehow,it keeps reducing LifeVar by 1 all the time instead of 0 25% of the time. (Like i used Ceil instead of round). Any fixes?
Currently: Semi-Active.
Working on: Maybe putting my test games in gamejolt, polishing them a bit, but I still don't know when.
User avatar
DeltaLeeds
 
Posts: 693
Joined: Fri May 06, 2011 12:45 pm
Location: In front of my computer.
Score: 38 Give a positive score

Re: Game errors

Postby skydereign » Sat Jul 07, 2012 11:41 pm

The problem is you are now using actual variables. Because of this you probably are using an int for your lives variable. ints do not preserve the floating point value. To fix this just edit the lives variable and change it to type real.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Game errors

Postby DeltaLeeds » Tue Jul 10, 2012 10:45 am

Thanks Skyde! It worked,sorry for not being on lately.... Things have been rough lately.. :(

EDIT: How to make enemies come to the player and have gravity at the same time? (Like the enemy can "see" the player and have gravity)
I tried Draw Actor=>Script editor=>
Code: Select all
yvelocity++;
MoveTo("Event Actor", 0.000000, 0.000000, 4.000000, "Player", "");

But it only executes the bottom line. What do I have to do to make them both execute?
P.S. I won't be online much due to internet problems.
Currently: Semi-Active.
Working on: Maybe putting my test games in gamejolt, polishing them a bit, but I still don't know when.
User avatar
DeltaLeeds
 
Posts: 693
Joined: Fri May 06, 2011 12:45 pm
Location: In front of my computer.
Score: 38 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron