The Daily Click ::. Forums ::. Klik Coding Help ::. fastloop trouble
 

Post Reply  Post Oekaki 
 

Posted By Message

Robbert



Registered
  19/06/2003
Points
  420
23rd October, 2005 at 16:26:31 -

Hello people,

For my soccer game there is a screen where the player can choose the country he wants to play with.

I have the names of the countries in an INI file called numberofcountries.INI
The is also a number-of-countries-item with value 8 for 8 countries in the game.

I have the flags of the countries in a map. They are all seperate bmp files which the player can edit himself if he thinks that the flags don't look right.

So here is my code:

Start of frame:
- Start loop "number-of-countries" for (INI: value from item "number-of-countries") times.

On loop "number-of-countries":
- Create Active picture at (92, 277)
- Set Xpos of Active picture to 92 + (49 * Loopindex(number-of-countries))
[[[49 is the distance between 2 flags with a 2 pixel space between them]]]
- New picture to Active picture: Appdrive$ + Appdir$ + "data/countries/" + string from item "country + Loopindex(number-of-countries)" + ".bmp"

So this could be in the INI file:

number-of-countries=4
country1=argentina
country2=brazil
country3=holland
country4=sweden

Now this all goes well... the only problem is that do not want a row of 60 countries, but I want rows of 4 flags and if the row is full set Y pos to a level lower... do you understand ?

I tried "loopindex = 5" --> set ypos one level lower...

but it won't work because a loop is too fast to properly recognize such a low number

anyone got a suggestion?

 
Hey mates, I'm Iglo yeah =P!

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
23rd October, 2005 at 17:02:56 -

Your problem is that it checks the loopindex outside of the loop. You can use:
On loop "number-of-countries"
+ loopindex <> 0 (Stops it from lowering the ypos on the first loop.)
+ loopindex mod 4 = 0 (This event is true if loopindex is divisible by four. Hence, it is triggered every fourth loopstep.)
--> set ypos one level lower.

 
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames

Robbert



Registered
  19/06/2003
Points
  420
23rd October, 2005 at 17:11:02 -

thanks mate. I was looking for such a button, I didn't know that Mod did that thanks

 
Hey mates, I'm Iglo yeah =P!

Robbert



Registered
  19/06/2003
Points
  420
23rd October, 2005 at 17:18:18 -

Yeah this is really great. It works already

The idea behind this is that players who like the game can add countries or later on clubs for themselves... or that i can bring out extension-packs for the game by download so i don't have to make a new game al these times.

thank you very much

 
Hey mates, I'm Iglo yeah =P!

Robbert



Registered
  19/06/2003
Points
  420
23rd October, 2005 at 17:36:41 -

By the way, since you're so good at knowing the meaning of the buttons ...

look... i have rows of 6 now, because 4 was to small for 78 countries (i was busy all day making those flags in paint, i could have just copied them from a site, but i liked it anyway )

so now I have 78 countries. that's 13 rows of 6 flags

now when the player decides to add a country (he has to draw a flag for it, name it in the INI file as country79=My Country and he has to change the number-of-countries from 78 to 79.

But then it's ready. His flag and the name will be loaded in to the game. I got that already.

But there is a window over the flags that you can control with the arrow keys to choose a country. that window has to know how far he can go in the table of countries. he knows that he can move 6 flags horizontal, but it has to know from the INI-file how many flag-positions it can move vertical.

Here is my code:

Alterable Value Y of Window < ((Item value number-of-countries / 6)-1)
+ Upon pressing "Down Arrow":

Set Alterable Value Y to Alt Val Y + 1

I have a formula to calculate the positions of the window by its Alterable X and Y values, something that looks like the formula of the load-countries thing.

But the code does something wrong. If there are 13 countries...

13/6 = 2

But the window has to scroll 3 lines! Because there is one flag that is in the 3rd row, on its own.

I hope you know if there is such a button that does like: 13/6 = 2,16 --> round it up --> 3

 
Hey mates, I'm Iglo yeah =P!

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
23rd October, 2005 at 21:52:06 -

Perhaps...
Set a counter at the beginning maxRows = numberOfCountries/6 - 1 (To keep your zero-based index)
If numberOfCountries mod 6 <> 0 --> add one to maxRows (x mod y gives the remainder leftover when x is divided by y. If it isn't zero, then you know that there will be an extra row that doesn't have the full six).
Make sure the above events only run once at the beginning of the program.

The length of the final row would be 6 if numberOfCountries mod 6 = 0, or numberOfCountries mod 6 if it doesn't. You can probably easily use this number to limit the x of the final row, since it won't always have a maximum of 6 flags.



Image Edited by the Author.

 
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames

Robbert



Registered
  19/06/2003
Points
  420
24th October, 2005 at 07:09:43 -

thanks. you must be making games for a long time

 
Hey mates, I'm Iglo yeah =P!
   

Post Reply



 



Advertisement

Worth A Click