Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the whole project to use addVertexWithUV instead of addVertex. Exit ... #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions Scripts/CharPicker.lua
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
-- Character selection screen

class "CharPicker" (Scene)

function CharPicker:CharPicker()
Scene.Scene(self, Scene.SCENE_3D)
self.pickerScreen = Scene(Scene.SCENE_2D)
self.archerLabel = SceneLabel("ARCHER (HARD)", 64, "main")
self.archerLabel:setPositionX((800-self.archerLabel:getWidth())/2)
self.archerLabel:setPositionY((300-self.archerLabel:getHeight())/2)
self.pickerScreen:getDefaultCamera():setOrthoSize(Services.Core:getXRes(), Services.Core:getYRes())
self.archerLabel = SceneLabel("ARCHER. HARD.", 64, "main")
self.archerLabel:setPositionY(150)
self.pickerScreen:addChild(self.archerLabel)

self.knightLabel = SceneLabel("KNIGHT (EASY)", 64, "main")
self.knightLabel:setPositionX((800-self.knightLabel:getWidth())/2)
self.knightLabel:setPositionY((300-self.knightLabel:getHeight())/2)
self.knightLabel = SceneLabel("KNIGHT. EASY.", 64, "main")
self.knightLabel:setPositionY(150)
self.pickerScreen:addChild(self.knightLabel)

self.wizardLabel = SceneLabel("WIZZARD (MEDIUM)", 64, "main")
self.wizardLabel:setPositionX((800-self.wizardLabel:getWidth())/2)
self.wizardLabel:setPositionY((300-self.wizardLabel:getHeight())/2)
self.wizardLabel = SceneLabel("WIZZARD. MEDIUM.", 64, "main")
self.wizardLabel:setPositionY(150)
self.pickerScreen:addChild(self.wizardLabel)

self.pickerScreen.enabled = false
Expand All @@ -29,24 +27,27 @@ function CharPicker:CharPicker()
self.rotator = Entity()
self:addChild(self.rotator)

self:getDefaultCamera():setPosition(0.005,0.05,0.3)
self:getDefaultCamera():setPosition(0,0.05,0.3)
self:getDefaultCamera():setClippingPlanes(0.0, 10.0)
self:getDefaultCamera():lookAt(Vector3(0.01,0,0), Vector3(0,1,0))
self:getDefaultCamera():lookAt(Vector3(0,0,0), Vector3(0,1,0))
self:getDefaultCamera():setFOV(30)

self.wizard = Creature(2)
self.rotator:addChild(self.wizard)
self.wizard:setPosition(-0,0,0.25)
self.wizard:setPosition(0,0,0.25)
self.wizard.shadow.visible = false

local sin30 = sin(rad(30))*0.25
local cos30 = cos(rad(30))*0.25

self.archer = Creature(1)
self.rotator:addChild(self.archer)
self.archer:setPosition(0.25,0,-0.25)
self.archer:setPosition(cos30,0,-sin30)
self.archer.shadow.visible = false

self.knight = Creature(0)
self.rotator:addChild(self.knight)
self.knight:setPosition(-0.25,0,-0.25)
self.knight:setPosition(-cos30,0,-sin30)
self.knight.shadow.visible = false

self.choice = 1
Expand Down
70 changes: 35 additions & 35 deletions Scripts/Creature.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function Creature:Creature(creatureIndex)
self.zAccel = 0

self.shadow = ScenePrimitive(ScenePrimitive.TYPE_PLANE, 0.08,0.08,0)
self.shadow:setPosition(0.0, 0.001, 0.00)
self.shadow:setPosition(scale*0.5, 0.001, 0.00)
self.shadow:setColor(1,1,1,0.78)
self.shadow.depthWrite = false
self.shadow:setMaterialByName("Shadow", Services.ResourceManager:getGlobalPool())
Expand Down Expand Up @@ -130,13 +130,13 @@ function Creature:Creature(creatureIndex)

self.baseXScale = 6

bodyMesh:addVertex((i*self.levelScale)+scale,0,(j*scale),1,0)
bodyMesh:addVertex((i*scale)+scale,sheight,(j*scale),1,1)
bodyMesh:addVertex((i*scale),sheight,(j*scale),0,1)
bodyMesh:addVertexWithUV((i*self.levelScale)+scale,0,(j*scale),1,0)
bodyMesh:addVertexWithUV((i*scale)+scale,sheight,(j*scale),1,1)
bodyMesh:addVertexWithUV((i*scale),sheight,(j*scale),0,1)

bodyMesh:addVertex((i*scale),0,(j*scale),0,0)
bodyMesh:addVertex((i*scale)+scale,0,(j*scale),1,0)
bodyMesh:addVertex((i*scale),sheight,(j*scale),0,1)
bodyMesh:addVertexWithUV((i*scale),0,(j*scale),0,0)
bodyMesh:addVertexWithUV((i*scale)+scale,0,(j*scale),1,0)
bodyMesh:addVertexWithUV((i*scale),sheight,(j*scale),0,1)

bodyMesh:calculateNormals()

Expand All @@ -146,19 +146,19 @@ function Creature:Creature(creatureIndex)
bodyMesh = Mesh(Mesh.TRI_MESH)
bodyMesh.indexedMesh = false

bodyMesh:addVertex((i*self.levelScale)+scale,0,(j*scale),0,0)
bodyMesh:addVertex((i*scale)+scale,sheight,(j*scale),0,1)
bodyMesh:addVertex((i*scale),sheight,(j*scale),1,1)
bodyMesh:addVertexWithUV((i*self.levelScale)+scale,0,(j*scale),0,0)
bodyMesh:addVertexWithUV((i*scale)+scale,sheight,(j*scale),0,1)
bodyMesh:addVertexWithUV((i*scale),sheight,(j*scale),1,1)

bodyMesh:addVertex((i*scale),0,(j*scale),1,0)
bodyMesh:addVertex((i*scale)+scale,0,(j*scale),0,0)
bodyMesh:addVertex((i*scale),sheight,(j*scale),1,1)
bodyMesh:addVertexWithUV((i*scale),0,(j*scale),1,0)
bodyMesh:addVertexWithUV((i*scale)+scale,0,(j*scale),0,0)
bodyMesh:addVertexWithUV((i*scale),sheight,(j*scale),1,1)

bodyMesh:calculateNormals()
self.lBody = SceneMesh.SceneMeshFromMesh(bodyMesh)

self.lBody:Translate(0,-self.levelScale,0)
self.rBody:Translate(0,-self.levelScale,0)
self.lBody:Translate(-scale,-self.levelScale,0)
self.rBody:Translate(-scale,-self.levelScale,0)

self.lBody:setMaterialByName("DragonBody", Services.ResourceManager:getGlobalPool())
self.rBody:setMaterialByName("DragonBody", Services.ResourceManager:getGlobalPool())
Expand All @@ -167,13 +167,13 @@ function Creature:Creature(creatureIndex)
--self.y = self.levelScale*4*0.5
else

bodyMesh:addVertex((i*scale)+scale,0,(j*scale),(indexX * cellSizeX) + cellSizeX,indexY*cellSizeY)
bodyMesh:addVertex((i*scale)+scale,sheight,(j*scale),(indexX * cellSizeX) + cellSizeX,(indexY * cellSizeY) + cellSizeY)
bodyMesh:addVertex((i*scale),sheight,(j*scale),indexX*cellSizeX,(indexY * cellSizeY) + cellSizeY)
bodyMesh:addVertexWithUV((i*scale)+scale,0,(j*scale),(indexX * cellSizeX) + cellSizeX,indexY*cellSizeY)
bodyMesh:addVertexWithUV((i*scale)+scale,sheight,(j*scale),(indexX * cellSizeX) + cellSizeX,(indexY * cellSizeY) + cellSizeY)
bodyMesh:addVertexWithUV((i*scale),sheight,(j*scale),indexX*cellSizeX,(indexY * cellSizeY) + cellSizeY)

bodyMesh:addVertex((i*scale),0,(j*scale),(indexX * cellSizeX),(indexY * cellSizeY))
bodyMesh:addVertex((i*scale)+scale,0,(j*scale),(indexX * cellSizeX)+cellSizeX,(indexY * cellSizeY))
bodyMesh:addVertex((i*scale),sheight,(j*scale),(indexX * cellSizeX),(indexY * cellSizeY)+cellSizeY)
bodyMesh:addVertexWithUV((i*scale),0,(j*scale),(indexX * cellSizeX),(indexY * cellSizeY))
bodyMesh:addVertexWithUV((i*scale)+scale,0,(j*scale),(indexX * cellSizeX)+cellSizeX,(indexY * cellSizeY))
bodyMesh:addVertexWithUV((i*scale),sheight,(j*scale),(indexX * cellSizeX),(indexY * cellSizeY)+cellSizeY)

bodyMesh:calculateNormals()
self.rBody = SceneMesh.SceneMeshFromMesh(bodyMesh)
Expand All @@ -184,19 +184,19 @@ function Creature:Creature(creatureIndex)
bodyMesh = Mesh(Mesh.TRI_MESH)
bodyMesh.indexedMesh = false

bodyMesh:addVertex((i*scale)+scale,0,(j*scale),(indexX * cellSizeX) - cellSizeX,indexY*cellSizeY)
bodyMesh:addVertex((i*scale)+scale,sheight,(j*scale),(indexX * cellSizeX) - cellSizeX,(indexY * cellSizeY) + cellSizeY)
bodyMesh:addVertex((i*scale),sheight,(j*scale),indexX*cellSizeX,(indexY * cellSizeY) + cellSizeY)
bodyMesh:addVertexWithUV((i*scale)+scale,0,(j*scale),(indexX * cellSizeX) - cellSizeX,indexY*cellSizeY)
bodyMesh:addVertexWithUV((i*scale)+scale,sheight,(j*scale),(indexX * cellSizeX) - cellSizeX,(indexY * cellSizeY) + cellSizeY)
bodyMesh:addVertexWithUV((i*scale),sheight,(j*scale),indexX*cellSizeX,(indexY * cellSizeY) + cellSizeY)

bodyMesh:addVertex((i*scale),0,(j*scale),(indexX * cellSizeX),(indexY * cellSizeY))
bodyMesh:addVertex((i*scale)+scale,0,(j*scale),(indexX * cellSizeX)-cellSizeX,(indexY * cellSizeY))
bodyMesh:addVertex((i*scale),sheight,(j*scale),(indexX * cellSizeX),(indexY * cellSizeY)+cellSizeY)
bodyMesh:addVertexWithUV((i*scale),0,(j*scale),(indexX * cellSizeX),(indexY * cellSizeY))
bodyMesh:addVertexWithUV((i*scale)+scale,0,(j*scale),(indexX * cellSizeX)-cellSizeX,(indexY * cellSizeY))
bodyMesh:addVertexWithUV((i*scale),sheight,(j*scale),(indexX * cellSizeX),(indexY * cellSizeY)+cellSizeY)

bodyMesh:calculateNormals()
self.lBody = SceneMesh.SceneMeshFromMesh(bodyMesh)

self.lBody:Translate(0,0,0)
self.rBody:Translate(0,0,0)
self.lBody:Translate(-scale,0,0)
self.rBody:Translate(-scale,0,0)

self.lBody:setMaterialByName("Creature", Services.ResourceManager:getGlobalPool())
self.rBody:setMaterialByName("Creature", Services.ResourceManager:getGlobalPool())
Expand All @@ -218,13 +218,13 @@ function Creature:Creature(creatureIndex)
local shieldMesh = Mesh(Mesh.TRI_MESH)
shieldMesh.indexedMesh = false

shieldMesh:addVertex((i*self.levelScale)+scale,0,(j*scale),1,0)
shieldMesh:addVertex((i*scale)+scale,sheight,(j*scale),1,1)
shieldMesh:addVertex((i*scale),sheight,(j*scale),0,1)
shieldMesh:addVertexWithUV((i*self.levelScale)+scale,0,(j*scale),1,0)
shieldMesh:addVertexWithUV((i*scale)+scale,sheight,(j*scale),1,1)
shieldMesh:addVertexWithUV((i*scale),sheight,(j*scale),0,1)

shieldMesh:addVertex((i*scale),0,(j*scale),0,0)
shieldMesh:addVertex((i*scale)+scale,0,(j*scale),1,0)
shieldMesh:addVertex((i*scale),sheight,(j*scale),0,1)
shieldMesh:addVertexWithUV((i*scale),0,(j*scale),0,0)
shieldMesh:addVertexWithUV((i*scale)+scale,0,(j*scale),1,0)
shieldMesh:addVertexWithUV((i*scale),sheight,(j*scale),0,1)

shieldMesh:calculateNormals()

Expand Down
5 changes: 4 additions & 1 deletion Scripts/HUD.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

require "Scripts/MainMenu"
require "Scripts/OptionsMenu"

class "HUD" (Scene)

Expand Down Expand Up @@ -43,6 +43,9 @@ function HUD:HUD()
self.mainMenu = MainMenu()
self:addChild(self.mainMenu)

self.optionsMenu = OptionsMenu()
self:addChild(self.optionsMenu)

self.flashRect = ScenePrimitive(ScenePrimitive.TYPE_VPLANE,160*2,160)
self:addChild(self.flashRect)
self.flashRect:setBlendingMode(Renderer.BLEND_MODE_NORMAL)
Expand Down
Loading