mirror of
https://github.com/bvanroll/3dsStuff.git
synced 2025-08-29 03:42:40 +00:00
ported the current code to 3ds, which meant there were some changes that had to be implemented: 3ds uses 255 for a scale for colors instead of floats between 0 and 1, getwidth actually doesn't give you the width, or maybe i didn't do it using the top screen gonna check that after this one, other weird stuff like the processor being too slow to exit out of a loop when something happens and it not doing it and trying to do the loop again so fixed that too...
This commit is contained in:
109
main.lua
109
main.lua
@@ -33,33 +33,6 @@ player = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
--[[
|
|
||||||
buttons for 3ds:
|
|
||||||
a
|
|
||||||
b
|
|
||||||
x
|
|
||||||
y
|
|
||||||
up
|
|
||||||
down
|
|
||||||
left
|
|
||||||
right
|
|
||||||
cpadup
|
|
||||||
cpaddown
|
|
||||||
cpadleft
|
|
||||||
cpadright
|
|
||||||
cstickup
|
|
||||||
cstickdown
|
|
||||||
cstickleft
|
|
||||||
cstickright
|
|
||||||
lbutton
|
|
||||||
rbutton
|
|
||||||
lzbutton
|
|
||||||
rzbutton
|
|
||||||
start
|
|
||||||
select
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
function player:reset()
|
function player:reset()
|
||||||
self.xvel = 0
|
self.xvel = 0
|
||||||
@@ -84,11 +57,11 @@ function player:move(xvel, yvel)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function player:update()
|
function player:update()
|
||||||
if self.x > hgrid then
|
if self.x > hgrid +4 then
|
||||||
self.x = 0
|
self.x = 0
|
||||||
end
|
end
|
||||||
if self.x < 0 then
|
if self.x < 0 then
|
||||||
self.x = hgrid
|
self.x = hgrid+4
|
||||||
end
|
end
|
||||||
if self.y > vgrid then
|
if self.y > vgrid then
|
||||||
self.y = 0
|
self.y = 0
|
||||||
@@ -97,9 +70,9 @@ function player:update()
|
|||||||
self.y = vgrid
|
self.y = vgrid
|
||||||
end
|
end
|
||||||
if self.tar.x == self.x and self.tar.y == self.y then
|
if self.tar.x == self.x and self.tar.y == self.y then
|
||||||
table.insert(self.blocks, {x = self.tar.x, self.tar.y})
|
table.insert(self.blocks, {x = self.x, y = self.y})
|
||||||
self.tar.x = math.floor(love.math.random() * hgrid)
|
self.tar.x = math.floor(math.random() * (hgrid+4))
|
||||||
self.tar.y = math.floor(love.math.random() * vgrid)
|
self.tar.y = math.floor(math.random() * vgrid)
|
||||||
beep:play()
|
beep:play()
|
||||||
end
|
end
|
||||||
for i = table.getn(self.blocks), 1, -1 do
|
for i = table.getn(self.blocks), 1, -1 do
|
||||||
@@ -115,30 +88,33 @@ function player:update()
|
|||||||
self.y = self.y+self.yvel
|
self.y = self.y+self.yvel
|
||||||
for i in ipairs(self.blocks) do
|
for i in ipairs(self.blocks) do
|
||||||
if self.x == self.blocks[i].x and self.y == self.blocks[i].y then
|
if self.x == self.blocks[i].x and self.y == self.blocks[i].y then
|
||||||
player:hardreset()
|
|
||||||
death:play()
|
death:play()
|
||||||
|
player:hardreset()
|
||||||
|
return
|
||||||
|
--love.event.quit()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function player:draw()
|
function player:draw()
|
||||||
love.graphics.setColor(0,1,0)
|
love.graphics.setScreen('top')
|
||||||
|
love.graphics.setColor(0,255,0)
|
||||||
temp = 0
|
temp = 0
|
||||||
for i in ipairs(self.blocks) do
|
for i in ipairs(self.blocks) do
|
||||||
temp = temp+1
|
temp = temp+1
|
||||||
|
x = self.blocks[i].x
|
||||||
|
y = self.blocks[i].y
|
||||||
love.graphics.rectangle(self.mode, self.blocks[i].x*self.w, self.blocks[i].y*self.w, self.w, self.w)
|
love.graphics.rectangle(self.mode, self.blocks[i].x*self.w, self.blocks[i].y*self.w, self.w, self.w)
|
||||||
end
|
end
|
||||||
love.graphics.print(temp)
|
love.graphics.setColor(self.col.r*255, 0, 0)
|
||||||
love.graphics.setColor(self.col.r, 0, 0)
|
|
||||||
love.graphics.rectangle(self.mode, self.tar.x * self.w, self.tar.y * self.w, self.w, self.w)
|
love.graphics.rectangle(self.mode, self.tar.x * self.w, self.tar.y * self.w, self.w, self.w)
|
||||||
love.graphics.setColor(self.col.r, self.col.g, self.col.b)
|
love.graphics.setColor(self.col.r*255, self.col.g*255, self.col.b*255)
|
||||||
love.graphics.rectangle(self.mode, self.x*self.w, self.y*self.w, self.w, self.w)
|
love.graphics.rectangle(self.mode, self.x*self.w, self.y*self.w, self.w, self.w)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function love.load()
|
function love.load()
|
||||||
--love.graphics.set3D(true)
|
--love.graphics.set3D(true)
|
||||||
beep:play()
|
|
||||||
player:hardreset()
|
player:hardreset()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -154,7 +130,7 @@ end
|
|||||||
function love.draw()
|
function love.draw()
|
||||||
love.graphics.setBackgroundColor(bgCol.r, bgCol.g, bgCol.b)
|
love.graphics.setBackgroundColor(bgCol.r, bgCol.g, bgCol.b)
|
||||||
--topscreen only works on 3ds, so look out
|
--topscreen only works on 3ds, so look out
|
||||||
love.graphics.setScreen('top')
|
--love.graphics.setScreen('top')
|
||||||
player:draw()
|
player:draw()
|
||||||
--bottom screen
|
--bottom screen
|
||||||
--love.graphics.setScreen('bottom')
|
--love.graphics.setScreen('bottom')
|
||||||
@@ -224,7 +200,7 @@ function love.keypressed(key)
|
|||||||
player:move(1, 0)
|
player:move(1, 0)
|
||||||
end
|
end
|
||||||
if (key == "select") then
|
if (key == "select") then
|
||||||
player:reset()
|
player:hardreset()
|
||||||
end
|
end
|
||||||
if (key == "lbutton") then
|
if (key == "lbutton") then
|
||||||
diff = diff - 10
|
diff = diff - 10
|
||||||
@@ -235,8 +211,59 @@ function love.keypressed(key)
|
|||||||
if (key == "rbutton") then
|
if (key == "rbutton") then
|
||||||
diff = diff + 10
|
diff = diff + 10
|
||||||
end
|
end
|
||||||
|
if (key == "l") then
|
||||||
|
diff = diff - 10
|
||||||
|
if diff < 9 then
|
||||||
|
diff = 10
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if (key == "r") then
|
||||||
|
diff = diff + 10
|
||||||
|
end
|
||||||
|
if (key == "lzbutton") then
|
||||||
|
diff = diff - 10
|
||||||
|
if diff < 9 then
|
||||||
|
diff = 10
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if (key == "rzbutton") then
|
||||||
|
diff = diff + 10
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.keyreleased(key)
|
function love.keyreleased(key)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--[[
|
||||||
|
buttons for 3ds:
|
||||||
|
a
|
||||||
|
b
|
||||||
|
x
|
||||||
|
y
|
||||||
|
up
|
||||||
|
down
|
||||||
|
left
|
||||||
|
right
|
||||||
|
cpadup
|
||||||
|
cpaddown
|
||||||
|
cpadleft
|
||||||
|
cpadright
|
||||||
|
cstickup
|
||||||
|
cstickdown
|
||||||
|
cstickleft
|
||||||
|
cstickright
|
||||||
|
lbutton
|
||||||
|
rbutton
|
||||||
|
lzbutton
|
||||||
|
rzbutton
|
||||||
|
start
|
||||||
|
select
|
||||||
|
|
||||||
|
|
||||||
|
]]
|
||||||
|
Reference in New Issue
Block a user