Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # bigbang.jl a utility for the Space Commander game
- using JSON
- cfgfile = "data/bigbang.json"
- LY = 9460730472580800 # light year in meters (exact)
- macro OK() @printf("\e[128C\e[4D\e[0m[\e[1;32mOK\e[0m]\n") end # [OK]
- @printf("\n\e[1;31mbigbang.jl \e[30mfor \e[34mSpace Commander\e[0m\n\n")
- print("Searching for configs...")
- # Galaxy Name
- # Read in the data file and get the configs # Origin System
- # Home World
- bbcfg = Dict() # Creator
- try # Systems
- open(cfgfile, "r") do f # Planets
- global bbcfg # Galaxy Size
- bbcfg=JSON.parse(readstring(f)) # Spiral Arms
- @OK # Variance
- end # Chaos
- catch
- @printf("\e[1;31mError: %s not found. Running GUI... ", cfgfile)
- run(`./bigb5`)
- exit()
- end
- @printf("Read %s :: \e[1;33mVersion %d", cfgfile, bbcfg["Version"]); @OK
- print("Loading functions... ")
- function discus() # return [x,y,z] attempts to make an elliptical blob
- s = rand()*bbcfg["Galaxy Size"]
- a = 2π * rand()
- b = (π/2 * exp(-0.07*s) * rand()) * rand([-1,1])
- r = [cos(b)*cos(a), cos(b)*sin(a), sin(b)] * s * LY
- return r
- end
- @OK
- @printf "Generating %s points... " bbcfg["Systems"]
- points = Array{Float64}(bbcfg["Systems"],3)
- for i in 1:bbcfg["Systems"]
- points[i,:] = discus()
- end
- @OK
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement