Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[solved] leaving for-loop after first turn - where is my mistake #337177
08/09/10 09:36
08/09/10 09:36
Joined: Jul 2010
Posts: 127
Germany, Herford
Ditje Offline OP
Member
Ditje  Offline OP
Member

Joined: Jul 2010
Posts: 127
Germany, Herford
I can`t see the wood because of the trees (german adage) grin

Following statement doesn`t work, beacuse enemy_distance get not counted up. But I don`t know why. There must be a very basic mistake in my thoughts.

Ditje

Code:
...
var enemy_distance = 2;
...
// Welle 1
var i;
for(i=1; i<9; i++)
{
   if(enemy_distance >= 2) 
   {
      if(i %2 == 0) 
      {
         enemy[i] = ent_create("bee2.mdl", vector(-50, 1000, 500), start_bee_wave1); 
         enemy_distance = 0;
      }
      else 
      {
         enemy[i] = ent_create("bee1.mdl", vector(-50, 1000, 500), start_bee_wave1);
         enemy_distance = 0;
      }
   }
   else enemy_distance += time_step;
}
...
wait(1);
...



Edit: if I remove wait(1) - I get entities until crash.

I create more entities by this loops(9-40). The ent_create functions of this entities don`t call a function yet and their loops work fine.

Code:
for(i=9; i<17; i++)
{
   if(i %2 == 0) enemy[i] = ent_create("bee2.mdl", vector(epos[i][0], -epos[i][1], epos[i][2]), NULL); 
   else ent_create("capture.mdl", vector(epos[i][0], -epos[i][1], epos[i][2]), NULL);
}



Last edited by Ditje; 08/10/10 08:50.
Re: leaving for-loop after first turn - where is my mistake? [Re: Ditje] #337190
08/09/10 12:34
08/09/10 12:34
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
I guess the problem must be in the actions of your entities.

Re: leaving for-loop after first turn - where is my mistake? [Re: Lukas] #337204
08/09/10 13:54
08/09/10 13:54
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
What is it you are "trying" to do?
This broken code makes no sense to me.

Why is the "enemy_distance += time_step;" in the "else" section?
Because of this, and the "var enemy_distance = 2;",
enemy_distance never get incremented, because the "else" never gets triggered.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: leaving for-loop after first turn - where is my mistake? [Re: EvilSOB] #337316
08/10/10 08:48
08/10/10 08:48
Joined: Jul 2010
Posts: 127
Germany, Herford
Ditje Offline OP
Member
Ditje  Offline OP
Member

Joined: Jul 2010
Posts: 127
Germany, Herford
Why should else not get triggered? When I create create an ENTITY enemy_distance gets set to 0 and 0 is smaller than 2 wink

But I am proud to annouce that I found a solution and reached my target. laugh Code for creating all enemies is now decreased from 138 lines to 45 lines.

Thanks an cheers

Ditje

Re: leaving for-loop after first turn - where is my mistake? [Re: Ditje] #337334
08/10/10 11:56
08/10/10 11:56
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Doh! Sorry. My bad. Was too tired and missed the obvious.

Good work on finding it yourself!


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

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