Hey Guys.
Im still working on my Universe generation.
Actual Situation:
I changed my TYPE TPlanet to Save the random generated Data for the planet itself and the specific System the planet is orbiting.
fe. Dim Planet(ID,System) as TPlanet.
global SystemID
global PlanetID
randomize timer()
//Planeten generieren
for SystemID=1 to 3
for PlanetID=1 to 7
GeneratePlanet(PlanetID, SystemID)
next PlanetID
next SystemID
do
print str$(Planet(1,1).ID)
print Planet(1,1).Name
print str$(Planet(1,1).System)
print str$(Planet(2,1).ID)
print Planet(2,1).Name
print str$(Planet(2,1).System)
loop
TYPE TPlanet
ID as Integer
Name as String
Typ as Integer
Size as Integer
Distance as Integer
AvgTemp as Integer
Speed as Float
Angle as Float
System as Integer
MinTemp as Integer
MaxTemp as Integer
ENDTYPE
Function GeneratePlanet(P_ID, P_SYS)
Dim Planet(P_ID, P_SYS) AS TPlanet // Für jeden Planeten einen eigenen Array generieren
Planet(P_ID, P_SYS).ID = P_ID
Planet(P_ID, P_SYS).System = P_SYS
Planet(P_ID, P_SYS).Name = RandomName(3)
Planet(P_ID, P_SYS).Typ = RND(6)+1 // TYP, Vulkan, Eis,...
Planet(P_ID, P_SYS).Size = RND(5)+1 // Planetengröße
Planet(P_ID, P_SYS).Distance = RND(10)+1 // Distance / Radius
Planet(P_ID, P_SYS).Speed = RND(10)+1
Planet(P_ID, P_SYS).Angle = RND(1000)
//Kollisionen untereinander vermeiden
if Planet(P_ID, P_SYS).ID = 2 then Planet(P_ID, P_SYS).Distance = Planet(P_ID-1, P_SYS).Size*2 + Planet(P_ID, P_SYS).Size*2+RND(5)+2
if Planet(P_ID, P_SYS).ID > 2 then Planet(P_ID, P_SYS).Distance = Planet(P_ID-1, P_SYS).Distance + RND(5)+Planet(P_ID-1, P_SYS).Size+Planet(P_ID, P_SYS).Size
remstart if P_ID = 1
Planet(P_ID, P_SYS).Typ = 1 // 1 = Sonne
Planet(P_ID, P_SYS).Size = RND(10)+7
Planet(P_ID, P_SYS).AvgTemp = RND(5000)+5000
//Make Object Sphere P_ID , Planet(P_ID, P_SYS).Size
//Set Point Light 0,0,0,15
//Color Light 0, RGB(255,255,200)
//Set Light Range 0, 70
else
//Make Object Sphere P_ID , Planet(P_ID, P_SYS).Size
//Move Object P_ID , Planet(P_ID, P_SYS).Distance
endif remend
EndFunction
Function RandomName(length)
RNDName$ as String
Dim Vokal$(5) as String
Vokal$(1) = "a"
Vokal$(2) = "e"
Vokal$(3) = "i"
Vokal$(4) = "o"
Vokal$(5) = "u"
Dim Konsonant$(21) as String
Konsonant$(1) = "b"
Konsonant$(2) = "c"
Konsonant$(3) = "d"
Konsonant$(4) = "f"
Konsonant$(5) = "g"
Konsonant$(6) = "h"
Konsonant$(7) = "j"
Konsonant$(8) = "k"
Konsonant$(9) = "l"
Konsonant$(10) = "m"
Konsonant$(11) = "n"
Konsonant$(12) = "p"
Konsonant$(13) = "q"
Konsonant$(14) = "r"
Konsonant$(15) = "s"
Konsonant$(16) = "t"
Konsonant$(17) = "v"
Konsonant$(18) = "w"
Konsonant$(19) = "x"
Konsonant$(20) = "y"
Konsonant$(21) = "z"
for i=1 to length
randomize timer()
RNDName$ = RNDName$+Konsonant$(RND(20)+1)
sleep 2
next i
RNDName$ = RNDName$+"-"+str$(RND(899)+100)
EndFunction RNDName$
Okay, that are some of the basic Functions.
I Just included the RandomName Function that you could test it.
My actual Problem is:
- I Call the GeneratePlanet Function.
- The first Planet(1,1) gets generated correctly
- Everything after that gets no Data. (You can see it in the printloop - No ID, No Name..)
The For-Next Loops are working correctly.
Im now trying it for 2 Days to get it running again. :s
worked perfectly until i made that array multidimensional
Any Help out there?
Thanks in Advance