1 registered members (henrybane),
732
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Need some help =)
[Re: Minamato]
#324826
05/23/10 15:59
05/23/10 15:59
|
Joined: Sep 2009
Posts: 993 Budapest
Aku_Aku
User
|
User
Joined: Sep 2009
Posts: 993
Budapest
|
As Lukas wrote: Also, it's better to not you hide and show panels like you do: right_pan.flags = 0; // hide the old paddle right_panbig.flags = SHOW | OVERLAY; // show the bigger paddle
Because setting the flags variable to 0 turns ALL flags off. This is bad if you want to keep other flags. Better do it like this: right_pan.flags &= ~SHOW; // hide the old paddle right_panbig.flags |= SHOW; // show the bigger paddle You should change your code from this:
paddlesmall_pan.flags = SHOW;
to this:
paddlesmall_pan.flags |= SHOW;
Try to think over your code. You set the SHOW attribute for entities, but where do you hide them? I advise to you insert this code:
paddlebig_pan.flags &= ~SHOW;
speedball_pan.flags &= ~SHOW;
paddlesmall_pan.flags &= ~SHOW;
doubleball_pan.flags &= ~SHOW;
In front of:
itemhilfe = integer(random(5)+1); // itemhilfe becomes something between 1 and 6
So all your entities will be invisible, but when the condition is true one (and only one) will be showed.
|
|
|
Re: Need some help =)
[Re: Aku_Aku]
#324828
05/23/10 16:05
05/23/10 16:05
|
Joined: Feb 2009
Posts: 80 STRING* location = "Germany";
Minamato
OP
Junior Member
|
OP
Junior Member
Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
|
thanks - I insert it. And sorry - changed all the things that Lukas said, but i used the code of my first reply and changed the "=" for showing you what I meant...^^" sry. ---------- i have now inserted the code you gave me into my sourcecode:
function items() // Funktion zum erstellen der Items
{
while(1)
{
paddlebig_pan.flags &= ~SHOW;
speedball_pan.flags &= ~SHOW;
paddlesmall_pan.flags &= ~SHOW;
doubleball_pan.flags &= ~SHOW;
itemhilfe = integer(random(5) + 1); // itemhilfe nimmt einen zufälligen Wert zwischen 1 und 5 an
if (itemhilfe == 1) // wenn die itemhilfe kleiner oder gleich 10 ist, aktiviere das PaddleBig-Item
{
paddlebig_pan.flags = SHOW;
paddlebig_pan.pos_x += 4*time_step;
paddlebig_pan.pos_y += 2*time_step;
if ((paddlebig_pan.pos_x >= 931) | (paddlebig_pan.pos_y >= 664))
{
paddlebig_pan.flags &= ~SHOW;
}
if ((paddlebig_pan.pos_y > right_pan.pos_y - 12) && (paddlebig_pan.pos_y < right_pan.pos_y + 96) && (paddlebig_pan.pos_x > 943) && (paddlebig_pan.pos_x < 955))
{
big_paddle();
paddlebig_pan.flags &= ~SHOW;
}
}
else if (itemhilfe == 2) // wenn die itemhilfe kleiner oder gleich 20 ist, aktiviere das SpeedBall-Item
{
speedball_pan.flags = SHOW;
speedball_pan.pos_x += 4*time_step;
speedball_pan.pos_y += 1*time_step;
if ((speedball_pan.pos_x >= 931) | (speedball_pan.pos_y >= 664))
{
speedball_pan.flags &= ~SHOW;
}
if ((speedball_pan.pos_y > right_pan.pos_y - 12) && (speedball_pan.pos_y < right_pan.pos_y + 96) && (speedball_pan.pos_x > 943) && (speedball_pan.pos_x < 955))
{
speedball_pan.flags &= ~SHOW;
ball_speed.x = 3 - 6 * (random(50) % 2); // -3 oder 3, Richtung, in die der Ball beim Start gespielt wird
ball_speed.y = 3 - random(6); // -3...3, zufällige vertikale Geschwindigkeit beim Start des Spiels
}
}
else if (itemhilfe == 3) // wenn die itemhilfe kleiner oder gleich 30 ist, aktiviere das PaddleSmall-Item
{
paddlesmall_pan.flags &= ~SHOW;
paddlesmall_pan.pos_x += 4*time_step;
paddlesmall_pan.pos_y += -1*time_step;
if ((paddlesmall_pan.pos_x >= 931) | (paddlesmall_pan.pos_y >= 664))
{
paddlesmall_pan.flags &= ~SHOW;
}
if ((paddlesmall_pan.pos_y > right_pan.pos_y - 12) && (paddlesmall_pan.pos_y < right_pan.pos_y + 96) && (paddlesmall_pan.pos_x > 943) && (paddlesmall_pan.pos_x < 955))
{
small_paddle();
paddlesmall_pan.flags &= ~SHOW;
}
}
else if (itemhilfe == 4) // wenn die itemhilfe kleiner oder gleich 40 ist, aktiviere das DoubleBall-Item
{
doubleball_pan.flags &= ~SHOW;
doubleball_pan.pos_x += 4*time_step;
doubleball_pan.pos_y += -2*time_step;
if ((doubleball_pan.pos_x >= 931) | (doubleball_pan.pos_y >= 664))
{
doubleball_pan.flags &= ~SHOW;
}
}
wait(1);
}
}
But now the item appears and moves flashing towards my paddle instead of just coming there...but why?
|
|
|
Re: Need some help =)
[Re: Minamato]
#324829
05/23/10 16:07
05/23/10 16:07
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
while (itemsactive = 1) ??? This loop never ends! indentation right:
while (1)
{
if (something == 1)
{
do_my_code
}
}
indentation false:
while (1)
{
if (something == 1)
{
do_my_code
}
}
if you make the indentation then your code is much easier to read. EDIT: you was faster ![wink wink](/ubb7/images/graemlins/default_dark/wink.gif)
Last edited by Widi; 05/23/10 16:08.
|
|
|
Re: Need some help =)
[Re: Widi]
#324839
05/23/10 16:35
05/23/10 16:35
|
Joined: Feb 2009
Posts: 80 STRING* location = "Germany";
Minamato
OP
Junior Member
|
OP
Junior Member
Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
|
Changed some of the // FALSE:
function items() // Funktion zum erstellen der Items
{
while(1)
{
paddlebig_pan.flags &= ~SHOW;
speedball_pan.flags &= ~SHOW;
paddlesmall_pan.flags &= ~SHOW;
doubleball_pan.flags &= ~SHOW;
itemhilfe = integer(random(5) + 1); // itemhilfe nimmt einen zufälligen Wert zwischen 1 und 5 an
if (itemhilfe == 1) // wenn die itemhilfe kleiner oder gleich 10 ist, aktiviere das PaddleBig-Item
{
paddlebig_pan.flags |= SHOW;
paddlebig_pan.pos_x += 4*time_step;
paddlebig_pan.pos_y += 2*time_step;
if ((paddlebig_pan.pos_x >= 931) | (paddlebig_pan.pos_y >= 664)) // FALSE
{
paddlebig_pan.flags &= ~SHOW;
}
if ((paddlebig_pan.pos_y > right_pan.pos_y - 12) && (paddlebig_pan.pos_y < right_pan.pos_y + 96) && (paddlebig_pan.pos_x > 943) && (paddlebig_pan.pos_x < 955))
{
big_paddle();
paddlebig_pan.flags &= ~SHOW;
}
}
else if (itemhilfe == 2) // wenn die itemhilfe kleiner oder gleich 20 ist, aktiviere das SpeedBall-Item
{
speedball_pan.flags |= SHOW;
speedball_pan.pos_x += 4*time_step;
speedball_pan.pos_y += 1*time_step;
if ((speedball_pan.pos_x >= 931) | (speedball_pan.pos_y >= 664)) // FALSE
{
speedball_pan.flags &= ~SHOW;
}
if ((speedball_pan.pos_y > right_pan.pos_y - 12) && (speedball_pan.pos_y < right_pan.pos_y + 96) && (speedball_pan.pos_x > 943) && (speedball_pan.pos_x < 955))
{
speedball_pan.flags &= ~SHOW;
ball_speed.x = 3 - 6 * (random(50) % 2); // -3 oder 3, Richtung, in die der Ball beim Start gespielt wird
ball_speed.y = 3 - random(6); // -3...3, zufällige vertikale Geschwindigkeit beim Start des Spiels
}
}
else if (itemhilfe == 3) // wenn die itemhilfe kleiner oder gleich 30 ist, aktiviere das PaddleSmall-Item
{
paddlesmall_pan.flags |= SHOW;
paddlesmall_pan.pos_x += 4*time_step;
paddlesmall_pan.pos_y += -1*time_step;
if ((paddlesmall_pan.pos_x >= 931) | (paddlesmall_pan.pos_y >= 664)) // FALSE
{
paddlesmall_pan.flags &= ~SHOW;
}
if ((paddlesmall_pan.pos_y > right_pan.pos_y - 12) && (paddlesmall_pan.pos_y < right_pan.pos_y + 96) && (paddlesmall_pan.pos_x > 943) && (paddlesmall_pan.pos_x < 955))
{
small_paddle();
paddlesmall_pan.flags &= ~SHOW;
}
}
else if (itemhilfe == 4) // wenn die itemhilfe kleiner oder gleich 40 ist, aktiviere das DoubleBall-Item
{
doubleball_pan.flags |= SHOW;
doubleball_pan.pos_x += 4*time_step;
doubleball_pan.pos_y += -2*time_step;
if ((doubleball_pan.pos_x >= 931) | (doubleball_pan.pos_y >= 664)) // FALSE
{
doubleball_pan.flags &= ~SHOW;
}
}
wait(1);
}
}
But what about the others? What's wrong with them?
|
|
|
Re: Need some help =)
[Re: Minamato]
#324840
05/23/10 16:36
05/23/10 16:36
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
if ((paddlebig_pan.pos_x >= 931) | (paddlebig_pan.pos_y >= 664)) // FALSE if ((paddlebig_pan.pos_x >= 931) || (paddlebig_pan.pos_y >= 664)) // RIGHT
Last edited by Widi; 05/23/10 16:36.
|
|
|
Re: Need some help =)
[Re: Widi]
#324841
05/23/10 16:42
05/23/10 16:42
|
Joined: Feb 2009
Posts: 80 STRING* location = "Germany";
Minamato
OP
Junior Member
|
OP
Junior Member
Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
|
So how you can see, I changed everything you said:
function items() // Funktion zum erstellen der Items
{
while(1)
{
paddlebig_pan.flags &= ~SHOW;
speedball_pan.flags &= ~SHOW;
paddlesmall_pan.flags &= ~SHOW;
doubleball_pan.flags &= ~SHOW;
itemhilfe = integer(random(5) + 1); // itemhilfe nimmt einen zufälligen Wert zwischen 1 und 5 an
if (itemhilfe == 1) // wenn die itemhilfe kleiner oder gleich 10 ist, aktiviere das PaddleBig-Item
{
paddlebig_pan.flags |= SHOW;
paddlebig_pan.pos_x += 4*time_step;
paddlebig_pan.pos_y += 2*time_step;
if ((paddlebig_pan.pos_x >= 931) || (paddlebig_pan.pos_y >= 664)) // FALSE
{
paddlebig_pan.flags &= ~SHOW;
}
if ((paddlebig_pan.pos_y > right_pan.pos_y - 12) && (paddlebig_pan.pos_y < right_pan.pos_y + 96) && (paddlebig_pan.pos_x > 943) && (paddlebig_pan.pos_x < 955))
{
big_paddle();
paddlebig_pan.flags &= ~SHOW;
}
}
else if (itemhilfe == 2) // wenn die itemhilfe kleiner oder gleich 20 ist, aktiviere das SpeedBall-Item
{
speedball_pan.flags |= SHOW;
speedball_pan.pos_x += 4*time_step;
speedball_pan.pos_y += 1*time_step;
if ((speedball_pan.pos_x >= 931) || (speedball_pan.pos_y >= 664)) // FALSE
{
speedball_pan.flags &= ~SHOW;
}
if ((speedball_pan.pos_y > right_pan.pos_y - 12) && (speedball_pan.pos_y < right_pan.pos_y + 96) && (speedball_pan.pos_x > 943) && (speedball_pan.pos_x < 955))
{
speedball_pan.flags &= ~SHOW;
ball_speed.x = 3 - 6 * (random(50) % 2); // -3 oder 3, Richtung, in die der Ball beim Start gespielt wird
ball_speed.y = 3 - random(6); // -3...3, zufällige vertikale Geschwindigkeit beim Start des Spiels
}
}
else if (itemhilfe == 3) // wenn die itemhilfe kleiner oder gleich 30 ist, aktiviere das PaddleSmall-Item
{
paddlesmall_pan.flags |= SHOW;
paddlesmall_pan.pos_x += 4*time_step;
paddlesmall_pan.pos_y += -1*time_step;
if ((paddlesmall_pan.pos_x >= 931) || (paddlesmall_pan.pos_y >= 664)) // FALSE
{
paddlesmall_pan.flags &= ~SHOW;
}
if ((paddlesmall_pan.pos_y > right_pan.pos_y - 12) && (paddlesmall_pan.pos_y < right_pan.pos_y + 96) && (paddlesmall_pan.pos_x > 943) && (paddlesmall_pan.pos_x < 955))
{
small_paddle();
paddlesmall_pan.flags &= ~SHOW;
}
}
else if (itemhilfe == 4) // wenn die itemhilfe kleiner oder gleich 40 ist, aktiviere das DoubleBall-Item
{
doubleball_pan.flags |= SHOW;
doubleball_pan.pos_x += 4*time_step;
doubleball_pan.pos_y += -2*time_step;
if ((doubleball_pan.pos_x >= 931) || (doubleball_pan.pos_y >= 664)) // FALSE
{
doubleball_pan.flags &= ~SHOW;
}
}
wait(1);
}
}
But my problem is now: I can see now all four items, moving flashing towards my paddle as if they are alternating...It's like the code is thinking: "big paddle! no! small paddle! no! double ball! no! fast ball! no!" etc...^^
|
|
|
|