Video puzzle

Show off your games, demos and other (playable) creations.
Post Reply
Xugro
Party member
Posts: 110
Joined: Wed Sep 29, 2010 8:14 pm

Video puzzle

Post by Xugro »

Hi folks,

I made a small and buggy video puzzle game. The goal is to drag and drop the pieces into the right position. The problem: the content of the puzzle pieces is changing :D.

To play the game you have to drag and drop a ogg-theora video into the game. You can find a small one (~15MB) here:
http://lachy.id.au/log/2007/06/webjam3

Known problems:
  • It sometimes crashes.
  • It does not like non video input.
  • Videos bigger than 800x600 are problematic.
  • It lags sometimes (on my machine).
Have fun!

Edit: The new version works without problems.
Attachments
video_puzzle_2.1.love
(2.44 KiB) Downloaded 228 times
Last edited by Xugro on Tue Dec 27, 2016 1:28 pm, edited 1 time in total.
User avatar
4aiman
Party member
Posts: 262
Joined: Sat Jan 16, 2016 10:30 am

Re: (buggy) video puzzle

Post by 4aiman »

This is COOL!!!!!!!!!!

Known problems:
  • Video does not loop
  • It lags sometimes
  • Clicking outside any piece crashes the game (100%): you need to add extra check on line #83:

    Code: Select all

     if pos[active_piece] then
  • Videos larger than 60Mb are problematic
Keep it up!
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: (buggy) video puzzle

Post by Ranguna259 »

This is actually pretty funny, even more if we use the video that you posted :P
But it is really slow and produces a lot of errors, I tried to tackle a few of them.
video thing.love
(1.92 KiB) Downloaded 162 times
With this version I fixed:
  • A bug when the player pressed on the screen before the video had been loaded.
  • Another bug when the player tried to press on a place with no pieces.
  • The lag problem.
Please unpack the .love file and search for lines that start with:

Code: Select all

--C
They are comments that I wrote so you can see what you did wrong.

You could also use less globals. Maybe organize all the variables inside a local table ?
Other than that, the code looks good, the snapping function is cool.
Anyway, this is really funny, keep it up. :nyu:
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
User avatar
4aiman
Party member
Posts: 262
Joined: Sat Jan 16, 2016 10:30 am

Re: (buggy) video puzzle

Post by 4aiman »

One more thing: a check for a stream format should be added. I.e. the app crashes when a wrong file format is dropped into it.
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: (buggy) video puzzle

Post by pgimeno »

Very cool idea, nice work!
4aiman wrote:Known problems:
  • Video does not loop
That's arguably a feature: if the video ends, your time is up :)

A problem I've found is that if all pieces are locked, but some are in wrong positions, it won't let you rearrange them to fix that. EDIT: Found why. The condition of win() should be amended by replacing the 'and' with an 'or', and swapping i and j after it. So, 'and (pos[(j-1)*number_of_rows+i][2]' becomes 'or (pos[(i-1)*number_of_rows+j][2]'

I've taken a look at the code. I was surprised that it used canvases instead of quads. I was told that switching canvases is a costly operation.
Xugro
Party member
Posts: 110
Joined: Wed Sep 29, 2010 8:14 pm

Re: (buggy) video puzzle

Post by Xugro »

Here is a new and faster version of the code. Take a look at the source if you like. The code should be easy to read.
4aiman wrote:One more thing: a check for a stream format should be added. I.e. the app crashes when a wrong file format is dropped into it.
That is still a thing I do not know how to do. Take a look at line 22 of main.lua. That's the best I could do, but even that does not work. Does anybody have a tip for me?
Attachments
video_puzzle_2.love
(1.89 KiB) Downloaded 149 times
bob_fossil
Prole
Posts: 17
Joined: Fri Apr 29, 2011 2:45 pm

Re: (buggy) video puzzle

Post by bob_fossil »

Xugro wrote:That is still a thing I do not know how to do. Take a look at line 22 of main.lua. That's the best I could do, but even that does not work. Does anybody have a tip for me?
The following function does some basic sanity tests to the file object you get from love.filedropped to see if it is in the supported format:

Code: Select all

function is_theora(file)

	local ok = false

	if not file then
		return ok
	end

	local filename = file:getFilename()
	-- Check for file ending with '.ogg'
	if not string.match(filename, ".+%.ogg$") then
		return ok
	end
		
	if file:open("r") then
		-- Read in the header.
		local header_size = 35
		local data = file:read(header_size)
		if #data==header_size then
			-- https://en.wikipedia.org/wiki/Ogg#File_format
			--
			-- Got expected header size.
			-- Get the magic number 'OggS' at offset 0.
			local magic = string.sub(data, 1, 4)
			-- Get the segment table at offset 28.
			-- Should be 'theora'.
			local segment = string.sub(data, 30, 36)
			if magic=="OggS" and segment=="theora" then
				ok = true
			end
		end
		file:close()
	end
	
	return ok
end
So you could call this function inside love.filedropped to verify the video file. Seems to work with the video file in the first post. You still need to make some changes or display an error message if an incorrect video file is dropped onto the window.
Xugro
Party member
Posts: 110
Joined: Wed Sep 29, 2010 8:14 pm

Re: (buggy) video puzzle

Post by Xugro »

bob_fossil wrote:The following function does some basic sanity tests to the file object you get from love.filedropped to see if it is in the supported format:
Thank you very much! :)

I hoped that there was an easier way to check this, but your solution should work pretty good.
bob_fossil wrote:You still need to make some changes or display an error message if an incorrect video file is dropped onto the window.
Done! :)
Attachments
video_puzzle_2.1.love
(2.44 KiB) Downloaded 143 times
bob_fossil
Prole
Posts: 17
Joined: Fri Apr 29, 2011 2:45 pm

Re: (buggy) video puzzle

Post by bob_fossil »

Xugro wrote:Thank you very much! :)

I hoped that there was an easier way to check this, but your solution should work pretty good.
You're welcome. Perhaps you can change the title of this thread now? :)
Xugro
Party member
Posts: 110
Joined: Wed Sep 29, 2010 8:14 pm

Re: (buggy) video puzzle

Post by Xugro »

bob_fossil wrote:Perhaps you can change the title of this thread now? :)
Done! :)

And I updated the first post to contain the newest version.
Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests