Compare commits
	
		
			2 Commits
		
	
	
		
			dd487f7b2b
			...
			f06f6e2ec0
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | f06f6e2ec0 | |
|  | ef648d556d | 
							
								
								
									
										46
									
								
								main.lua
								
								
								
								
							
							
						
						
									
										46
									
								
								main.lua
								
								
								
								
							|  | @ -1,7 +1,12 @@ | |||
| g3d = require "g3d" | ||||
| require "suppfunc" | ||||
| 
 | ||||
| function love.load() | ||||
| 	math.randomseed(os.time()) | ||||
| 	-- Personal seed generation | ||||
| 	personalseed = love.data.encode("string", "hex", love.data.hash("sha256", os.getenv("PATH"))) | ||||
| 	notsorandomseed = tonumber(personalseed, 16) | ||||
| 	math.randomseed(notsorandomseed) | ||||
| 	 | ||||
| 	-- GRAPHICS | ||||
| 		-- GOOD PIXEL | ||||
| 	love.graphics.setDefaultFilter("nearest") | ||||
|  | @ -21,20 +26,33 @@ function love.load() | |||
| end | ||||
| 
 | ||||
| function love.mousemoved(x,y, dx,dy) | ||||
| 	g3d.camera.firstPersonLook(dx,dy) | ||||
| 	if not pause then | ||||
| 		g3d.camera.firstPersonLook(dx,dy) | ||||
| 	end | ||||
| end | ||||
| 
 | ||||
| function love.update(dt) | ||||
| 	g3d.camera.firstPersonMovement(dt,5) | ||||
|    | ||||
| 	if not pause then | ||||
| 		g3d.camera.firstPersonMovement(dt,5) | ||||
| 	end | ||||
| end | ||||
| 
 | ||||
| function love.keypressed(key) | ||||
| 	if key == "z" then  | ||||
| 		obj_list = {} | ||||
| 		math.randomseed(os.time()) | ||||
| 		notsorandomseed = os.time() | ||||
| 		math.randomseed(notsorandomseed ) | ||||
| 		generate_museum(0,0,0) | ||||
| 	end | ||||
| 	if key == "escape" then  | ||||
| 		if pause then | ||||
| 			pause = false | ||||
| 			love.mouse.setRelativeMode(true) | ||||
| 		else | ||||
| 			pause = true | ||||
| 			love.mouse.setRelativeMode(false) | ||||
| 		end | ||||
| 	end | ||||
| end | ||||
|   | ||||
| function love.draw() | ||||
|  | @ -42,12 +60,26 @@ function love.draw() | |||
| 	for _, obj in pairs(obj_list) do | ||||
| 		obj:draw() | ||||
| 	end | ||||
|  	 | ||||
| 	-- print coords | ||||
| 
 | ||||
| 	-- print "Press [z] to generate a new museum" | ||||
| 	love.graphics.print("Press [z] to generate a new museum", 20, 20) | ||||
| 
 | ||||
| 	-- print coords | ||||
| 	love.graphics.print("x: "..math.floor(g3d.camera.position[1])..", y: "..math.floor(g3d.camera.position[2])..", z: "..math.floor(g3d.camera.position[3]), 20, 40) | ||||
| 
 | ||||
| 	-- print seed | ||||
| 	if notsorandomseed == tonumber(personalseed, 16) then | ||||
| 		love.graphics.setColor(hexrgb("#FFD700")) | ||||
| 		love.graphics.print("Seed: "..personalseed, 20, 60) | ||||
| 		love.graphics.setColor(hexrgb("#ffffff")) | ||||
| 	else | ||||
| 		love.graphics.print("Seed: "..notsorandomseed, 20, 60) | ||||
| 	end | ||||
| 
 | ||||
| 
 | ||||
| 	if pause then | ||||
| 		love.graphics.rectangle("fill", 20, 20, love.graphics.getWidth()-40, love.graphics.getHeight()-40) | ||||
| 	end | ||||
| end | ||||
| 
 | ||||
| function generate_museum(x,y,z) | ||||
|  |  | |||
|  | @ -0,0 +1,34 @@ | |||
| 
 | ||||
| 
 | ||||
| -- Converts HEXRGB to RGB | ||||
| function hexrgb(hashtag) | ||||
|   hashtag = string.lower(hashtag) | ||||
|   local r1 = hex_to_dec(hashtag:sub(2,2)) | ||||
|   local r2 = hex_to_dec(hashtag:sub(3,3)) | ||||
|   local g1 = hex_to_dec(hashtag:sub(4,4)) | ||||
|   local g2 = hex_to_dec(hashtag:sub(5,5)) | ||||
|   local b1 = hex_to_dec(hashtag:sub(6,6)) | ||||
|   local b2 = hex_to_dec(hashtag:sub(7,7)) | ||||
| 
 | ||||
|   return (r1*16 + r2)/255, (g1*16 + g2)/255, (b1*16 + b2)/255 | ||||
| end   | ||||
| 
 | ||||
| function hex_to_dec(hex) | ||||
|   if hex == "0"      then return 0 | ||||
|   elseif hex == "1"  then return 1 | ||||
|   elseif hex == "2"  then return 2 | ||||
|   elseif hex == "3"  then return 3  | ||||
|   elseif hex == "4"  then return 4 | ||||
|   elseif hex == "5"  then return 5  | ||||
|   elseif hex == "6"  then return 6 | ||||
|   elseif hex == "7"  then return 7 | ||||
|   elseif hex == "8"  then return 8 | ||||
|   elseif hex == "9"  then return 9 | ||||
|   elseif hex == "a"  then return 10 | ||||
|   elseif hex == "b"  then return 11 | ||||
|   elseif hex == "c"  then return 12 | ||||
|   elseif hex == "d"  then return 13 | ||||
|   elseif hex == "e"  then return 14 | ||||
|   elseif hex == "f"  then return 15 | ||||
|   end | ||||
| end | ||||
		Loading…
	
		Reference in New Issue