Page 1 of 1

SÖLAR, a fairly simple solar system simulator

Posted: Wed Nov 21, 2012 4:12 pm
by Ubermann
FsTOy.png
FsTOy.png (14.24 KiB) Viewed 647 times

New and planned features shown in the app itself in the help pannel.

DOWNLOAD IT HERE:
(direct link to .love attachments)
Version 0.91
Screenshot here
download/file.php?mode=view&id=6152


Additional credits to:
Saegor: realtime stars algorithm


More to come.

Enjoy.

Re: SÖLAR, a fairly simple solar system simulator

Posted: Wed Nov 21, 2012 5:25 pm
by Saegor
nice !

[... bla bla ...]

Re: SÖLAR, a fairly simple solar system simulator

Posted: Thu Nov 22, 2012 8:56 am
by Ubermann
Saegor wrote:nice !

i wrote a bit of code for your stars (if you want)

EDIT : new code

etc etc etc
Cool.

I added it to the my original code.

I gave the option to switch between three background modes: "black background", "static image background" and "realtime stars background", because for slow or old computers your realtime stars may cause slowdows, so the "player" can choose which mode to use.
Also I changed the "hide orbit lines" to "change orbit lines translucency".

blah blah blah read down.

Re: SÖLAR, a fairly simple solar system simulator

Posted: Thu Nov 22, 2012 4:30 pm
by Ubermann
Tweaked version released with:

- Saegon realtime stars, rotating static starfield and all-black background
- Some GUI changes
- Added help pannel and simple app logo
- Some serious code changes
- Initial implementation of mouse support
- Tooltips when hovering mouse over any plater (more planet info will come ofc)
- Some slightly speed improvements
- Maybe something else I can't remember now.

Details in 1st post.

Re: SÖLAR, a fairly simple solar system simulator

Posted: Thu Nov 22, 2012 5:15 pm
by Saegor
New version of Sölar space background.

Changelog :
- important changes codewise : now 3 files (main.lua, stars.lua, comets.lua)

main.lua

Code: Select all

function love.load()

	gr = love.graphics
	getW = gr.getWidth()
	getH = gr.getHeight()
	
	require "stars"
	require "comets"
end

function love.update(dt)

	stars:update()
	if comet.e then comet:update(dt) end
end

function love.draw()

	stars:draw()
	if comet.e then comet:draw() end
end

function love.keypressed(key)

	if key == "escape"
	or key == "return" then
	
		love.event.push("quit")
	end
	
	if key == "tab"
	or key == " " then
	
		comet:new()
	end
end
stars.lua

Code: Select all

stars = {}

for i = 1, 0x400 do

	stars[i] = {}
	
	stars[i].x, stars[i].y, stars[i].n =
	
		math.random(0, getW),
		math.random(0, getH),
		math.random(0, 0xff)
end

function stars:update(dt)

	for k, _ in ipairs(self) do
	
		local m = math.random(-0x08, 0x08)
	
		self[k].n = self[k].n + m
		
		if self[k].n < 0x10 then
		
			self[k].n = 0x10
			
		elseif self[k].n > 0xff then
		
			self[k].n = 0xff
		end
	end
end

function stars:draw()

	for k, _ in ipairs(self) do
	
		local c = self[k].n
		gr.setColor(0xff, 0xff, 0xff, c)
		gr.point(self[k].x, self[k].y)
	end
end
comets.lua

Code: Select all

comet = {}

for i = -10, 10, 4 do

	table.insert(comet, i)
end

function comet:new()

	self.e = true
	
	self.dx = self[math.random(#self)]
	self.dy = self[math.random(#self)]

	if math.random(2) > 1 then

		self.x = getW/2 - self.dx/math.abs(self.dx) * getW/2
		self.y = math.random(0, getH)
	else

		self.x = math.random(0, getW)
		self.y = getH/2 - self.dy/math.abs(self.dy) * getH/2
	end
end

function comet:update(dt)
	
	self.x = self.x + self.dx * dt * 0x40
	self.y = self.y + self.dy * dt * 0x40

	if self.x < - getW	or self.x > getW * 2
	or self.y < - getW	or self.y > getH * 2 then
	
		self.e = nil
	end
end

function comet:draw()

	for i = 16, 1, -1 do
	
		local c = 0x80/i
		
		gr.setColor(0xff, 0xff, 0xff, c)
		
		gr.line(
			self.x, self.y,
			self.x - i * self.dx, self.y - i * self.dy
		)
	end
end
space.love
license is public domain
(1.13 KiB) Downloaded 221 times
press tab or space to see a comet

Re: SÖLAR, a fairly simple solar system simulator

Posted: Thu Nov 22, 2012 7:36 pm
by qaisjp
looks quite nice, actually.