Homebrew [Release] - LövePotion - LÖVE API for 3DS Homebrew - BETA

haazet

Well-Known Member
Newcomer
Joined
Dec 15, 2015
Messages
64
Trophies
0
XP
159
Country
United States
Oh your right, ive been testing on Citra and cannot move. But just threw on my n3ds moves just fine. Maybe I not pressing the correct key in Citra. Anyone know the Keyboard Bindings? Thanks for responding

-- LövePotion example/no game screen

-- love.load() is called once when a LövePotion game is ran.
function love.load()

-- Enables 3D mode.
love.graphics.set3D(true)

-- Seeds the random number generator with the time (Actually makes it random)
math.randomseed(os.time())

-- Sets the current screen for draw calls to draw to.
-- Lasts until it is called again.
love.graphics.setScreen('top')

logo = {} -- Creates a table to hold variables for the logo (x, y, image etc.)

-- Sets the logo position to the center of the screen, using love.graphics.getWidth()/getHeight()
-- and Image:getWidth()/getHeight()
logo.x = 200
logo.y = 120

--Me adding Speed
logo.speed = 10


potionText = {} -- Creates a table to hold variables for the text

font = love.graphics.newFont() -- Creates a new font, when no arguments are given it uses the default font

-- Loads images from filepaths
logo.image = love.graphics.newImage('rightskim.png')
background = love.graphics.newImage('BeachWave.png')

inspector = love.graphics.newImage('bottommenu.png')
message = love.graphics.newImage('nogame.png')
messagebg = love.graphics.newImage('bubble.png')



-- Sets the texts position, by setting variables in the potionText table
potionText.x = 50
potionText.y = 75

-- Load the beep sound from a .raw file to play on exit
exitSound = love.audio.newSource('beep.wav')

-- Sets the background color to a nice blue
love.graphics.setBackgroundColor(88, 186, 255)



end

-- love.update(dt) is called every frame, and is used for game logic.
-- The dt argument is delta-time, the average time between frames.
-- Use this to make your game framerate independent.
function love.update(dt)

if love.keyboard.isDown("left") then
logo.x = logo.x - logo.speed*dt
elseif love.keyboard.isDown("right") then
logo.x = logo.x + logo.speed*dt
end


end

-- love.draw() is called every frame. Any and all draw code goes here. (images, shapes, text etc.)
function love.draw()

-- Start drawing to the top screen
love.graphics.setScreen('top')

-- Reset the current draw color to white
love.graphics.setColor(255, 255, 255)

-- Draw the background image
love.graphics.draw(background, 0, 0)


-- Draws the framerate
love.graphics.setColor(255, 255, 255)
love.graphics.rectangle('fill', 10, 15, font:getWidth('FPS: ' .. love.timer.getFPS()) + 10, font:getHeight() + 3)
love.graphics.setColor(35, 31, 32)
love.graphics.setFont(font)
love.graphics.print('FPS: ' .. love.timer.getFPS(), 15, 15)

love.graphics.setColor(255, 255, 255)

-- Draw Player
love.graphics.draw(logo.image, logo.x, logo.y)

-- Start drawing to the bottom screen
love.graphics.setScreen('bottom')

-- Draw the baby inspector with the no-game text
love.graphics.draw(inspector, 0, 0)
love.graphics.draw(messagebg, 160, 0)
love.graphics.draw(message, 185, 10)

end




-- love.keypressed is called when any button is pressed.
-- The argument key is the key that was pressed.
-- Not all input code goes here, if you want to check if a button is down then
-- use love.update(dt) along with love.keyboard.isDown().
function love.keypressed(key)

-- If the start button is pressed, we return to the Homebrew Launcher
if key == 'start' then
love.event.quit()
end

end

-- love.quit is called when LövePotion is quitting.
-- You can put all your cleanup code and the likes here.
function love.quit()

-- Plays the exit beep sound.
exitSound:Play()

end
 

haazet

Well-Known Member
Newcomer
Joined
Dec 15, 2015
Messages
64
Trophies
0
XP
159
Country
United States
I solved my problem, I must check "Use HardwareRenderer" to get input for some reason. May help someone else
 

VideahGams

Well-Known Member
OP
Newcomer
Joined
Aug 29, 2015
Messages
91
Trophies
0
Age
26
Location
Glasgow, Scotland
Website
videah.xyz
XP
156
Country
@VideahGams Is it possible to use physics? I'm trying to make an object so that when the main character touches it he dies.

Physics aren't required for this, you can just check if the two objects are touching each other like this:

Code:
local box1 = {x = 15, y = 15, width = 10, height = 10}
local box2 = {x = 0, y = 0, width = 20, height = 20}

-- The overlap function.
local function overlap(x1, y1, w1, h1, x2, y2, w2, h2)
   return x1 < x2 + w2 and
     y1 < y2 + h2 and
     x2 < x1 + w1 and
     y2 < y1 + h1
end

if overlap(box1.x, box1.y, box1.width, box1.height, box2.x, box2.y, box2.width, box2.height) then

   -- Both of the boxes are overlapping, so the function `overlap` returns true.
   -- When they aren't overlapping (say box2's width and height were set to 5)
   -- then it would return false.

   -- Do your stuff here.

end
However, if you think this is too messy there are libs to make it easier (although a bit overkill) such as bump.lua or HardonCollider.
 

haazet

Well-Known Member
Newcomer
Joined
Dec 15, 2015
Messages
64
Trophies
0
XP
159
Country
United States
Im having trouble to get the blank touchscreen control my player that is on the upper screen. Im trying to find some examples but having cant seem to see it. I think have mouse movement down if he was on the lower screen

love.update
--Still Updating Mouse Movement
if love.mouse.isDown then --Check every frame if left mouse button is down
local mousex, mousey = love.mouse.getPosition() --Get mousex and mousey because it's not given to us
player.move_to(mousex, mousey)
end

This is the player.moveto function that i use on my player = {}
function player.move_to(_x, _y)
dx = _x - player.x
dy = _y - player.y
length = math.sqrt(dx*dx+dy*dy);

dx = (dx/length)
dy = (dy/length)

player.x = (player.x + dx * player.speed)
player.y = (player.y + dy * player.speed)
end
 

Attachments

  • idkuga.rar
    187.5 KB · Views: 238

VideahGams

Well-Known Member
OP
Newcomer
Joined
Aug 29, 2015
Messages
91
Trophies
0
Age
26
Location
Glasgow, Scotland
Website
videah.xyz
XP
156
Country
Im having trouble to get the blank touchscreen control my player that is on the upper screen. Im trying to find some examples but having cant seem to see it. I think have mouse movement down if he was on the lower screen

love.update
--Still Updating Mouse Movement
if love.mouse.isDown then --Check every frame if left mouse button is down
local mousex, mousey = love.mouse.getPosition() --Get mousex and mousey because it's not given to us
player.move_to(mousex, mousey)
end

This is the player.moveto function that i use on my player = {}
function player.move_to(_x, _y)
dx = _x - player.x
dy = _y - player.y
length = math.sqrt(dx*dx+dy*dy);

dx = (dx/length)
dy = (dy/length)

player.x = (player.x + dx * player.speed)
player.y = (player.y + dy * player.speed)
end

love.mouse.isDown is a function not a variable, so your touch code should look like this:
Code:
if love.mouse.isDown('l') then --Check every frame if left mouse button is down
   local mousex, mousey = love.mouse.getPosition() --Get mousex and mousey because it's not given to us
   player.move_to(mousex, mousey)
end
 

haazet

Well-Known Member
Newcomer
Joined
Dec 15, 2015
Messages
64
Trophies
0
XP
159
Country
United States
ah thanks agian, really learning a lot here. Moved the code from update to draw section and is working now) Although quite rough haha

Edit: dropped my player speed from 100 to 10 and is smooth.
 
Last edited by haazet,

haazet

Well-Known Member
Newcomer
Joined
Dec 15, 2015
Messages
64
Trophies
0
XP
159
Country
United States
Ive got my Scrolling background running in Citra but on a real 3ds is just blank? Edit: I had speed defined too for bg1


--Scrolling
windowx = love.graphics.getWidth()

bg1 = {}
bg1.img = love.graphics.newImage("back1.png")
bg1.x = 0
bg1.width = bg1.img:getWidth()

speed = 30

function love.draw(dt)
love.graphics.draw(bg1.img, bg1.x, 0)

function love.update(dt)


--BG Scrolling
bg1.x = bg1.x - speed * dt
 
Last edited by haazet,

TurtleP

Well-Known Member
Member
Joined
Oct 7, 2015
Messages
140
Trophies
0
Age
28
Website
TurtleP.github.io
XP
308
Country
United States
Here's my Löve 0.10.0 3DS compatibility library to make it "emulate" 3DS. It doesn't do 3D. Just change the extension from .txt to .lua and require it. There's also a keyboard configuration table to set certain keys as buttons to a 3DS.

EDIT: Fixed a minor bug
EDIT 2: Fixed another thing (though you just need _EMULATEHOMEBREW set to true in the old version)
 

Attachments

  • 3ds.txt
    4.8 KB · Views: 226
Last edited by TurtleP,

Substance12

Well-Known Member
Member
Joined
Aug 2, 2015
Messages
562
Trophies
0
XP
549
Country
Argentina
I need to stop playing a sound, but i've tried with love.audio.stop and with nameofsound:stop and nothing seems to work, it keeps on playing.

What can I do?
 

Tobold

Member
Newcomer
Joined
Jan 13, 2016
Messages
8
Trophies
0
Age
40
XP
52
Country
Gambia, The
Ooooh! I'm excited about this!

Two questions:

What values does the setDepth accept? I take it, the higher the value the "deeper" it is "in the screen"?

Any chance of getting ogg or mp3 support?
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: Well start walking towards them +1