Page 1 of 2

Game errors

PostPosted: Sun Jul 01, 2012 7:15 pm
by DeltaLeeds
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?

Re: Text colour help

PostPosted: Sun Jul 01, 2012 9:09 pm
by skydereign
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.

How to shoot Projectiles?

PostPosted: Mon Jul 02, 2012 4:32 am
by DeltaLeeds
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?

Re: Game errors

PostPosted: Mon Jul 02, 2012 11:00 am
by schnellboot
something like this?

Re: Game errors

PostPosted: Mon Jul 02, 2012 11:06 am
by DeltaLeeds
I see the script now! Thanks Schnell! xD

How to remove decimal

PostPosted: Mon Jul 02, 2012 3:56 pm
by DeltaLeeds
I have another question,how to remove decimals in numbers?

Re: Game errors

PostPosted: Mon Jul 02, 2012 3:58 pm
by schnellboot
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?

Re: Game errors

PostPosted: Mon Jul 02, 2012 5:30 pm
by skydereign
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

Re: Game errors

PostPosted: Tue Jul 03, 2012 8:31 am
by DeltaLeeds
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.

Re: Game errors

PostPosted: Wed Jul 04, 2012 3:59 pm
by Bee-Ant
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;
}

A new level

PostPosted: Thu Jul 05, 2012 8:20 am
by DeltaLeeds
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?

Re: A new level

PostPosted: Fri Jul 06, 2012 7:26 am
by Wertyboy
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

Re: Game errors

PostPosted: Fri Jul 06, 2012 7:32 am
by DeltaLeeds
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?

Re: Game errors

PostPosted: Sat Jul 07, 2012 11:41 pm
by skydereign
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.

Re: Game errors

PostPosted: Tue Jul 10, 2012 10:45 am
by DeltaLeeds
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.