But love.window.isVisible works properly? ffffuuuuu
EDIT: I think I found the issue, but the fix will probably be a bit hacky... oh well.
Testing the new things in 0.9.0
Re: Testing the new things in 0.9.0
Yep, love.window.isVisible works just great, sorry!
Here's an example of creating a SoundData and a Source from a base64 encoded string, and a couple of new SoundData methods:
Blend modes!
replace is new, and alpha and multiplicative are different.
Here's an example of creating a SoundData and a Source from a base64 encoded string, and a couple of new SoundData methods:
Code: Select all
function love.load()
data = 'RXh0ZW5kZWQgTW9kdWxlOiBzb2x... etc. Check out the .love file to test it!'
filedata = love.filesystem.newFileData(data, '.xm', 'base64')
sounddata = love.sound.newSoundData(filedata)
source = love.audio.newSource(filedata)
source:play()
end
function love.draw()
love.graphics.print('Number of samples: '..sounddata:getSampleCount(), 0, 0)
love.graphics.print('\nDuration: '..sounddata:getDuration()..' seconds', 0, 0)
end
Blend modes!
replace is new, and alpha and multiplicative are different.
Re: Testing the new things in 0.9.0
love.math.random and such!
love.timer.getAverageDelta!
Inspired by http://sol.gfxile.net/gp/ch02.html
Code: Select all
function love.load()
love.window.setMode(450, 170)
love.math.randomseed(123)
s = 'The random number generator is portable.\nIf you run this, you should also get the numbers ' ..
love.math.random(100) .. ', ' ..
love.math.random(100) .. ', and ' ..
love.math.random(100) .. '.\n\n'
rg1 = love.math.newRandomGenerator()
rg1:randomseed(123)
rg2 = love.math.newRandomGenerator(123)
s = s .. '(Which are also '..
rg1:random(100)..' and '..rg2:random(100)..', '..
rg1:random(100)..' and '..rg2:random(100)..', and '..
rg1:random(100)..' and '..rg2:random(100)..'!)\n\n'
s = s .. 'These numbers are the same:\n'..
rg1:random()..'\n'..
rg2:random()..'\n\nAnd '..
rg1:random(100, 200)..' is the same number as '..
rg2:random(100, 200)
end
function love.draw()
love.graphics.print(s, 15, 15)
end
Code: Select all
function love.load()
width = 300
height = 200
love.window.setMode(width, height)
imagedata = love.image.newImageData(width, height)
image = love.graphics.newImage(imagedata)
color = {255, 0, 255}
end
function do_thing()
r = love.math.randomnormal(50)
a = math.floor(r) + width/2
for i = imagedata:getHeight()-1, 0, -1 do
if a >= 0 and a <= width-1 then
if imagedata:getPixel(a, i) == 0 then
-- ImageData:setPixel now accepts a table with optional alpha.
imagedata:setPixel(a, i, color)
break
end
end
end
end
function love.update(dt)
do_thing()
do_thing()
do_thing()
do_thing()
do_thing()
-- Image:refresh reloads an Image using the ImageData that created it.
image:refresh()
end
function love.draw()
love.graphics.draw(image)
end
Inspired by http://sol.gfxile.net/gp/ch02.html
Code: Select all
function love.load()
height = 100
width = 200
love.window.setMode(width, height)
oh = love.image.newImageData(width, height)
yes = love.graphics.newImage(oh)
end
function love.update()
time = love.timer.getTime() * 100
oh:mapPixel(function(x, y) return decimal_to_rgb(y * y + x * x + time) end)
yes:refresh()
end
function love.draw()
love.graphics.draw(yes)
love.graphics.print(
'Average delta:\n' ..
love.timer.getAverageDelta() * 1000 .. ' ms', 10, 35)
end
function decimal_to_rgb(n)
local r = math.floor(n / (256*256))
local g = math.floor((n - (r * (256*256))) / 256)
local b = n - (r * 256*256) - (g * 256)
return r, g, b
end
Re: Testing the new things in 0.9.0
Well, Shaders seem to be well & happy.
- Attachments
-
- fluid.love
- Simple shader for Love 0.9
- (902 Bytes) Downloaded 116 times
Re: Testing the new things in 0.9.0
Font filtering and love.graphics.printf!
Code: Select all
function love.load()
love.window.setMode(650, 100)
font = love.graphics.getFont()
end
function love.draw()
-- The filter style of Fonts can be set.
-- When setFilter is given one argument, it is used when the object is either magnified or minified.
font:setFilter('nearest')
-- love.graphics.printf has "justify" align mode and transformation parameters.
love.graphics.printf(
'This is a test!',
10, 10, -- position
200, -- width
'justify', -- align mode
0, -- rotation
3, nil, -- x and y axis scale (y axis defaults to x axis)
0, 0, -- offset
-0.3, 0 -- x and y axis shear
)
font:setFilter('linear')
love.graphics.printf(
'This is a test!',
10, 50, -- position
200, -- width
'left', -- align mode
0, -- rotation
3, nil, -- x and y axis scale (y axis defaults to x axis)
0, 0, -- offset
-0.3, 0 -- x and y axis shear
)
end
Last edited by Santos on Thu Sep 19, 2013 4:29 am, edited 1 time in total.
- slime
- Solid Snayke
- Posts: 3163
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Testing the new things in 0.9.0
FYI the 'justify' AlignMode is pretty broken right now. It needs major fixing/rewriting before it'll match real justified alignment.
Re: Testing the new things in 0.9.0
[quote="Santos"]So I thought it would be cool to have a thread when 0.9.0 is released to talk about and show examples of the new functionality, but then I thought, why wait, it could be useful to talk about what's new now so it can be documented and tested with the nightly builds.
quote]
Just wondering where you live - that the nights are so long.
The last 'nightly build' was on June 24.
quote]
Just wondering where you live - that the nights are so long.
The last 'nightly build' was on June 24.
Re: Testing the new things in 0.9.0
I'd guess Valve HQRef wrote:Just wondering where you live - that the nights are so long.Santos wrote:So I thought it would be cool to have a thread when 0.9.0 is released to talk about and show examples of the new functionality, but then I thought, why wait, it could be useful to talk about what's new now so it can be documented and tested with the nightly builds.
The last 'nightly build' was on June 24.
Your screen is very zoomed in...
- slime
- Solid Snayke
- Posts: 3163
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Testing the new things in 0.9.0
Boolsheet's nightly builds for Windows are more up to date:
https://bitbucket.org/Boolsheet/love_wi ... ev-x64.zip
https://bitbucket.org/Boolsheet/love_wi ... ev-x86.zip
You can see when they were last updated by clicking on the 'branches' section here: https://bitbucket.org/Boolsheet/love_winbin/downloads
https://bitbucket.org/Boolsheet/love_wi ... ev-x64.zip
https://bitbucket.org/Boolsheet/love_wi ... ev-x86.zip
You can see when they were last updated by clicking on the 'branches' section here: https://bitbucket.org/Boolsheet/love_winbin/downloads
Re: Testing the new things in 0.9.0
Cursors!
This uses:
love.mouse.newCursor
love.mouse.setCursor
love.mouse.getCursor
[wiki]Cursor:getType[/wiki]
Click or scroll to change cursors.
I'm wondering, why do new Cursors have to be created from CursorTypes rather than passing the CursorType to setCursor, since only one style of Cursor can be made from each CursorType? Something like this doesn't seem to make sense:
This uses:
love.mouse.newCursor
love.mouse.setCursor
love.mouse.getCursor
[wiki]Cursor:getType[/wiki]
Click or scroll to change cursors.
Code: Select all
function love.load()
watermelon = love.image.newImageData(love.filesystem.newFileData('iVBORw0KGgoAAAANSUhEUgAAABAAAAAdCAMAAACUsxyNAAAAG1BMVEUAAAD//8xm/2YAZgAAiAAAAAD/AJkAVQAAuwCd2kQ+AAAAAXRSTlMAQObYZgAAAHBJREFUeF6F0EEKQyEAA1GT/Nre/8QVDYNQoC4fE0E9kmRcJ5Z8SzSnKkAFeCEUFYCGCQ0TGqANExoKmgISJmsgtaBPUtBWAfIBF+RUNnhvxQvzed4JCfD8gHVPxgJLzn5dFi84JR8JIP+glzeonMEXBYEFSfnXZfkAAAAASUVORK5CYII=', '', 'base64'))
cursors = {
love.mouse.newCursor('arrow'),
love.mouse.newCursor('ibeam'),
love.mouse.newCursor('wait'),
love.mouse.newCursor('waitarrow'),
love.mouse.newCursor('crosshair'),
love.mouse.newCursor('sizenwse'),
love.mouse.newCursor('sizenesw'),
love.mouse.newCursor('sizewe'),
love.mouse.newCursor('sizens'),
love.mouse.newCursor('sizeall'),
love.mouse.newCursor('no'),
love.mouse.newCursor('hand'),
love.mouse.newCursor(watermelon, 0, 0)
}
i = 1
end
function love.draw()
local cursor = love.mouse.getCursor()
if cursor then
love.graphics.print('Current cursor: ' .. cursor:getType(), 0, 0)
else
love.graphics.print('Current cursor: default', 0, 0)
end
end
function love.mousepressed(x, y, b)
if b == 'l' or b == 'wu' then
i = i - 1
if i < 1 then
i = #cursors
end
elseif b == 'r' or b == 'wd' then
i = i + 1
if i > #cursors then
i = 1
end
end
love.mouse.setCursor(cursors[i])
end
Code: Select all
cursor1 = love.mouse.newCursor('arrow')
cursor2 = love.mouse.newCursor('arrow')
Who is online
Users browsing this forum: Ahrefs [Bot] and 4 guests