Skip to content

Commit

Permalink
0.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Nixinova committed Jan 5, 2021
1 parent 3393620 commit 1ec6fdf
Show file tree
Hide file tree
Showing 20 changed files with 179 additions and 108 deletions.
Binary file modified Data/Fonts/Mineo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Data/Maps/Crashed Ship.png
Binary file not shown.
Binary file removed Data/Models/Crashed Ship.png
Binary file not shown.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
10 changes: 10 additions & 0 deletions Data/Scripts/Game/EscapeToMenu.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function Behavior:Awake()

end

function Behavior:Update()
if CS.Input.WasButtonJustReleased("Escape") then
local menuScene = CraftStudio.FindAsset("Main Menu", "Scene")
CraftStudio.LoadScene(menuScene)
end
end
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
-- BlockPlayer obj --

hotbar = {
hotbar = { -- blocks obj is in 'World generation'
blocks.stone, blocks.clay, blocks.dirt, blocks.grass, blocks.oak_log,
blocks.oak_leaf, blocks.sand, blocks.tin, blocks.copper, blocks.asphalt
}

-- blocks obj is in 'World generation'
local selectedBlock = blocks.stone
local currentSlot = 1
selectedBlock = blocks.stone
currentSlot = 1
showCoords = 1
canBuild = true

local tick = 0
local canBuild = true

function Behavior:Update()
tick = tick + 1

local player = CS.FindGameObject("Player")
local playerPos = player.transform:GetPosition()
local aimPos = self.gameObject.transform:GetPosition()
local coords = CS.FindGameObject("Coords")
local mapObject = CS.FindGameObject("Map")
local map = mapObject:GetComponent("MapRenderer"):GetMap()
local north = Map.BlockOrientation.North

local worldYOffset = mapObject.transform:GetPosition().y/2

local blockPreviewObject = CS.FindGameObject("BlockPreview")
local blockSelection = CS.FindGameObject("SelectedBlock")

-- Toggle build
if CS.Input.WasButtonJustPressed("ToggleBuild") then
canBuild = not canBuild
end

-- Change item slot
for i=1,10,1 do
if CS.Input.WasButtonJustPressed("Item" .. i) then
currentSlot = i
Expand All @@ -40,12 +46,11 @@ function Behavior:Update()
if currentSlot > 10 then currentSlot = 1 end
if currentSlot < 1 then currentSlot = 10 end

-- Build preview
selectedBlock = hotbar[currentSlot]

local pos = self.gameObject.transform:GetPosition()
local x = math.floor(pos.x/2+0.5)
local y = math.floor(pos.y/2+0.5)
local z = math.floor(pos.z/2+0.5)
local x = math.floor(aimPos.x/2+0.5)
local y = math.floor(aimPos.y/2+0.5)
local z = math.floor(aimPos.z/2+0.5)
if canBuild then
blockSelection.transform:SetLocalPosition(Vector3:New(-3.08+currentSlot*0.56, 0.8125, 0))
blockPreviewObject.transform:SetPosition(Vector3:New(x*2, y*2-4, z*2))
Expand All @@ -54,28 +59,46 @@ function Behavior:Update()
blockPreviewObject.transform:SetPosition(Vector3:New(0, 0, 0))
end

-- Build
if CS.Input.IsButtonDown("RClick") and canBuild and tick > 10 then
if map:GetBlockIDAt(x,y,z) == blocks.air then
map:SetBlockAt(x,y,z, selectedBlock, north)
map:SetBlockAt(x,y-worldYOffset,z, selectedBlock, north)
tick = 0
end
end
if CS.Input.IsButtonDown("LClick") and canBuild and tick > 10 then
map:SetBlockAt(x,y,z, blocks.air, north)
map:SetBlockAt(x,y-worldYOffset,z, blocks.air, north)
tick = 0
end


-- Nuke
local nukeSize = 2 -- 5x5x5
if CS.Input.WasButtonJustPressed("Nuke") then
for i=-nukeSize,nukeSize,1 do
for j=-nukeSize,nukeSize,1 do
for k=-nukeSize,nukeSize,1 do
if math.randomrange(0,5) > 1 then
map:SetBlockAt(x+i,y+j,z+k, blocks.air, north)
map:SetBlockAt(x+i,y+j-worldYOffset,z+k, blocks.air, north)
end
end
end
end
end

-- Coords
local posX = tostring(playerPos.y).format("%.1f", playerPos.x/2)
local posY = tostring(playerPos.y).format("%.1f", playerPos.y/2-worldYOffset-0.25)
local posZ = tostring(playerPos.y).format("%.1f", playerPos.z/2)
local posText = posX .. ' / ' .. posY .. ' / ' .. posZ

if CS.Input.WasButtonJustReleased("ToggleCoords") then
showCoords = showCoords + 1
end

if showCoords % 2 == 0 then
coords.textRenderer:SetText(posText)
else
coords.textRenderer:SetText('')
end

end
26 changes: 0 additions & 26 deletions Data/Scripts/Game/Position.lua

This file was deleted.

4 changes: 4 additions & 0 deletions Data/Scripts/Game/SetMapFriction.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function Behavior:Awake()
-- Disable vertical friction
self.gameObject.physics:SetAnisotropicFriction( Vector3:New( 1, 0, 1 ) )
end
9 changes: 0 additions & 9 deletions Data/Scripts/Game/Ship placement.lua

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

local debug = false

local mapSize = 64
mapSize = 64
minXZ = -mapSize
maxXZ = mapSize
north = Map.BlockOrientation.North
Expand All @@ -18,17 +18,18 @@ blocks = {
air = 255
}

local completedMap = false
completedMap = false

function Behavior:Start()
if completedMap == false then
print("World generation start")
if not completedMap then
print("World generation started")
local map = self.gameObject:GetComponent("MapRenderer"):GetMap()

local n = 0

local grassMax = 8
local grassY = math.randomrange(grassMax-2,grassMax)
local worldSmoothness = 4 -- higher = more smooth
local grassMax = 16
local grassY = worldType == 'normal' and math.randomrange(grassMax-2,grassMax) or grassMax
local undergroundLvl = grassMax-4
local grassChange = 1
local chunkSize = 4
Expand Down Expand Up @@ -67,11 +68,14 @@ if completedMap == false then
end
end

local grassChangeChance = math.random(0,2)
if grassChangeChance == 0 then
grassChange = math.random(-1,1)
-- chunk grass Y average level
if worldType == 'normal' then
local grassChangeChance = math.random(0,worldSmoothness)
if grassChangeChance == 0 then
grassChange = math.random(-1,1)
end
grassY = math.round(math.randomrange(grassY+grassChange, grassMax))
end
grassY = math.round(math.randomrange(grassY+grassChange, grassMax))

for X=x, x+chunkSize, 1 do
for Z=z, z+chunkSize, 1 do
Expand Down Expand Up @@ -163,13 +167,14 @@ if completedMap == false then
map:SetBlockAt(x, maxTreeY+1, z, leafType, north)
end

-- grass Y change
local grassChngChance = math.random(-20,20)
if grassChngChance == -1 then
grassY = grassY - 1
-- local grass Y change
if worldType == 'normal' then
local grassChangeChance = math.random(0, worldSmoothness*10)
if grassChangeChance == 0 then
grassY = grassY - 1
elseif grassChangeChance == 1 then
grassY = grassY + 1
end
if grassChngChance == 1 then
grassY = grassY + 1
end

end
Expand All @@ -181,17 +186,19 @@ if completedMap == false then
print("World generation done")

-- ship
n = 16
while n < 24 do
local shipMinY = grassY+8
local shipMaxY = grassY+16
n = shipMinY
while n < shipMaxY do
for X=-3,3,1 do for Z=-3,3,1 do
map:SetBlockAt(X, n, Z, blocks.air, north)
end end
n = n + 1
end

-- floor
n = 16
while n > 8 do
n = shipMinY
while n > shipMinY-8 do
for X=-3,3,1 do for Z=-3,3,1 do
map:SetBlockAt(X, n, Z, blocks.asphalt, north)
end end
Expand All @@ -216,8 +223,8 @@ if completedMap == false then
end

-- walls
n = 17
while n < 24 do
n = shipMinY+1
while n < shipMaxY do
for X=-1,1,2 do
for Z=-1,1,2 do
for X1=-3,3,1 do for Z1=-3,3,1 do
Expand Down Expand Up @@ -251,26 +258,23 @@ if completedMap == false then

-- roof
for X=-3,3,1 do for Z=-3,3,1 do
if math.random(0,1) == 0 then map:SetBlockAt(X, 24, Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(X, shipMaxY, Z, blocks.tin, north) end
end end
for X=-1,1,2 do for Z=-1,1,2 do
if math.random(0,1) == 0 then map:SetBlockAt(6*X, 24, 0*Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(6*X, 24, 1*Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(5*X, 24, 2*Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(4*X, 24, 2*Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(3*X, 24, 3*Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(2*X, 24, 4*Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(2*X, 24, 5*Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(1*X, 24, 6*Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(0*X, 24, 6*Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(6*X, shipMaxY, 0*Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(6*X, shipMaxY, 1*Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(5*X, shipMaxY, 2*Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(4*X, shipMaxY, 2*Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(3*X, shipMaxY, 3*Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(2*X, shipMaxY, 4*Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(2*X, shipMaxY, 5*Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(1*X, shipMaxY, 6*Z, blocks.tin, north) end
if math.random(0,1) == 0 then map:SetBlockAt(0*X, shipMaxY, 6*Z, blocks.tin, north) end
end end
print("Ship generation done")
end

print("Map complete")
completedMap = true
end
end

function Behavior:Update()
end
7 changes: 0 additions & 7 deletions Data/Scripts/Indev/Block placing.lua

This file was deleted.

13 changes: 0 additions & 13 deletions Data/Scripts/Indev/Raycast.lua

This file was deleted.

Loading

0 comments on commit 1ec6fdf

Please sign in to comment.