Coder Social home page Coder Social logo

love-example-browser's People

Contributors

ahmed-dardery avatar darkfrei avatar janwerder avatar rm-code avatar s-ol avatar shampine avatar slowb33 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

love-example-browser's Issues

examples/011_animation.lua Bug and Fix, version love 11.2

Bug Show

bug-show

it Twinkling

Fixing

We need to fix two files examples/011_animation.lua and animation.lua

examples/011_animation.lua

source

-- Example: Create and use an Animation
require("animation")

function newImagePO2(filename)
	local source = love.image.newImageData(filename)
	local w, h = source:getWidth(), source:getHeight()
	
	-- Find closest power-of-two.
	local wp = math.pow(2, math.ceil(math.log(w)/math.log(2)))
	local hp = math.pow(2, math.ceil(math.log(h)/math.log(2)))

	-- Only pad if needed:
	if wp ~= w or hp ~= h then
	local padded = love.image.newImageData(wp, hp)
	padded:paste(source, 0, 0)
	return love.graphics.newImage(padded)
	end

	return love.graphics.newImage(source)
end

function love.load()
	-- Set a lovely pink background color.
	love.graphics.setBackgroundColor(0.96, 0.77, 0.87)
	
	-- Load the source of the animation.
	img = newImagePO2("assets/anim-boogie.png")
	
	-- Create an animation with a frame size of 32x32 and
	-- 0.1s delay betwen each frame.
	animation1 = newAnimation(img, 32, 32, 0.1, 6)
end

function love.update(dt)
	-- The animation must be updated so it 
	-- knows when to change frames.
	animation1:update(dt)
end

function love.draw()
	-- Draw the animation the center of the screen.
	animation1:draw(400, 300, 0, 1, 1)
end

The image source w and h are 96✖️64, but wp and hp become 128✖️64 after -- Find closest power-of-two. calculate。

anim

assets/anim-boogie.png size doesn't right anymore.

fix to: can we just comment on the calculating part?

animation.lua

source

...
	for i = 1, frames do
		local row = math.floor(i/rowsize) -- rowsize is 3
		local column = i%rowsize
		local frame = love.graphics.newQuad(column*fw, row*fh, fw, fh, imgw, imgh)
		table.insert(a.frames, frame)
		table.insert(a.delays, delay)
	end
...

Depending on newAnimation(img, 32, 32, 0.1, 6) example code above. frames == 6, for 1 to 6(included).

So, the row value will be 0 0 1 1 1 2 in the loop for. the processing like this:

1: local row = math.floor(0/3) => 0
2: ...
3: local row = math.floor(3/3) => 1
...
6: local row = math.floor(6/3) => 2

Ending result just cut the 1st 32✖️32 png on the first row. lose one png in whole frames.

fix to i = 0 and frames - 1, so the loop from 0 to 5:

frames = frames - 1
for i = 0, frames do
		local row = math.floor(i/rowsize) -- rowsize is 3
		local column = i%rowsize
		local frame = love.graphics.newQuad(column*fw, row*fh, fw, fh, imgw, imgh)
		table.insert(a.frames, frame)
		table.insert(a.delays, delay)
	end

End: row value 0 0 0 1 1 1

fixed

Shader example

There should be a simple Shader example. Maybe we can combine it with the love2d book

Make a gh-page with the examples on a webpage.

I tested the example.love with lovejs and it work fine the only examples that don't are ones involving the mouse cursor or video. It would be convenient to have them in the browser.

License?

Under what license it this code?
I am in particularly interested whether i have to rewrite the selector code and it's dependencies.

Inconsistant indentation in code

Some of the code uses 4-column indent, while other code uses tabs. Some files contain a mix of both styles, making them hard to edit. What's the official word on indentation style for this project?

Simple GUI Example

There should be a simple GUI Example, that shows how to create a simple button with a click event.

Serialization example

There should be a simple Serialization example that shows how to save your objects to disk.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.