Gamestudio Links
Zorro Links
Newest Posts
Lapsa's very own thread
by Lapsa. 06/26/24 12:45
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (henrybane), 732 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mino, squik, AemStones, LucasJoshua, Baklazhan
19061 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 4 1 2 3 4
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 Offline
User
Aku_Aku  Offline
User

Joined: Sep 2009
Posts: 993
Budapest
As Lukas wrote:
Quote:
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:
Code:
paddlesmall_pan.flags = SHOW;


to this:
Code:
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:
Code:
paddlebig_pan.flags &= ~SHOW;
speedball_pan.flags &= ~SHOW;
paddlesmall_pan.flags &= ~SHOW;
doubleball_pan.flags &= ~SHOW;


In front of:
Code:
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 Offline OP
Junior Member
Minamato  Offline 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:

Code:
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 Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
while (itemsactive = 1) ??? This loop never ends!

indentation right:

Code:
while (1)
{
   if (something == 1)
   {
      do_my_code
   }
}



indentation false:

Code:
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

Last edited by Widi; 05/23/10 16:08.
Re: Need some help =) [Re: Widi] #324831
05/23/10 16:10
05/23/10 16:10
Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
Minamato Offline OP
Junior Member
Minamato  Offline OP
Junior Member

Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
no problem =) I saw that my loop never ends and changed it before wink and the identation was just wrong because I used "quote" instead of "code" in UBB grin

Re: Need some help =) [Re: Widi] #324834
05/23/10 16:24
05/23/10 16:24
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
Code:
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;  // FALSE  
         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;   // FALSE 
         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);
   }
}


I mark the faults with "FALSE" in your code. And so have to be a corrected indentation look... wink



Last edited by Widi; 05/23/10 17:24.
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 Offline OP
Junior Member
Minamato  Offline OP
Junior Member

Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
Changed some of the // FALSE:

Code:
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 Offline
Serious User
Widi  Offline
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 Offline OP
Junior Member
Minamato  Offline OP
Junior Member

Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
So how you can see, I changed everything you said:

Code:
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...^^

Re: Need some help =) [Re: Minamato] #324845
05/23/10 17:17
05/23/10 17:17
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
One question, i dont understand your code:
You have all in a while loop. So "itemhilfe" becomes every frame a new value. Is this right? I dont think so, but i dont know all your code...

Re: Need some help =) [Re: Widi] #324847
05/23/10 17:26
05/23/10 17:26
Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
Minamato Offline OP
Junior Member
Minamato  Offline OP
Junior Member

Joined: Feb 2009
Posts: 80
STRING* location = "Germany";
I want that the function is like a die - depending on which number is disgorged, an item shall appear. specific in this function:

1 -> big paddle
2 -> faster ball
3 -> small paddle
4 -> double ball

I put it into a while loop so that an item appears every one minute (I hid the wait(-60) after the while(1) for testing if the code is right

Page 2 of 4 1 2 3 4

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1