SquareZ

Show off your games, demos and other (playable) creations.
Post Reply
Xyore
Prole
Posts: 6
Joined: Thu Oct 09, 2014 11:40 pm

SquareZ

Post by Xyore »

You've probably heard of this game. Does Picross ring a bell? Or more obscurely, CubeMania, that homebrew game for the PSP.

Well, this is pretty much that.

What makes this special, at least for me, is that this game was made from scratch without knowledge in how to make these types of games. If there's one thing I'm (sort of) good at, it's reverse-engineering games. Even if just small, basic games.

That's enough about me. Why not give it a shot? It's free! And if you have any feedback, awesome!

Note: I made this on a small lil' laptop and for some reason it ran pretty slow at times (game freezing,input lag, etc.), so I'm not sure if it's just me or the game. If anyone can figure it out for me, I'll highly appreciate it.

Edit: v1.1 comes with the following changes:
- changed the way the game checked if you won to account for multiple solutions
- small optimizations
- font changes
- grid size indicator
- other small stuff
Attachments
SquareZ.love
(2.34 KiB) Downloaded 234 times
Last edited by Xyore on Wed Sep 09, 2015 5:09 am, edited 2 times in total.
User avatar
arampl
Party member
Posts: 248
Joined: Mon Oct 20, 2014 3:26 pm

Re: SquareZ

Post by arampl »

1. love.graphics.setNewFont can be bottleneck here. Check warning (yellow background) on its Wiki page. You should create all fonts in love.load and use love.graphics.setFont later on.

2. love.graphics.getWidth / love.graphics.getHeight don't need to be called from love.update. Use love.resize event.
And use love.mousemoved event to get mx & my (exists since LÖVE v. 0.9.2).

3. love.graphics.setBackgroundColor(bgColor) can also be called only once from love.load.

To summarize all this info - move all unnesessary stuff from love.draw & love.update to other events.


4. You don't need setBorder at all. Again, love.graphics.setLineWidth goes to love.load and change loop in love.draw to:
EDIT: I'm wrong here.

Code: Select all

	for i=1,gridSize do
		for j=1,gridSize do
			if player[i][j] == 1 then love.graphics.setColor(tileColor)
			else love.graphics.setColor(bgColor)
			end
			x, y, w, h = gx+(i-1)*(gs/gridSize),gy+(j-1)*(gs/gridSize),gs/gridSize,gs/gridSize
			love.graphics.rectangle("fill", x, y, w, h)
			love.graphics.setColor(txtColor)
			love.graphics.rectangle("line", x, y, w, h)
		end
	end
5. Study and make use of canvases. This way you don't need to redraw each cell (until resize occures).

EDIT: I can also recommend never use "magic numbers" like 800, 600 right in the code. Use variables with meaningful names. It applies to any programming language.
User avatar
rmcode
Party member
Posts: 454
Joined: Tue Jul 15, 2014 12:04 pm
Location: Germany
Contact:

Re: SquareZ

Post by rmcode »

For some reason I expected a zombie survival game with cubes :D

A small issue I found: When you open the help with F1 and press escape the game will close after your press 'OK' on the help panel.
Xyore
Prole
Posts: 6
Joined: Thu Oct 09, 2014 11:40 pm

Re: SquareZ

Post by Xyore »

rmcode wrote:For some reason I expected a zombie survival game with cubes :D

A small issue I found: When you open the help with F1 and press escape the game will close after your press 'OK' on the help panel.
I don't think I'm able to fix that as love.window.showMessageBox() is a built-in function.
arampl wrote:1. love.graphics.setNewFont can be bottleneck here. Check warning (yellow background) on its Wiki page. You should create all fonts in love.load and use love.graphics.setFont later on.

2. love.graphics.getWidth / love.graphics.getHeight don't need to be called from love.update. Use love.resize event.
And use love.mousemoved event to get mx & my (exists since LÖVE v. 0.9.2).

3. love.graphics.setBackgroundColor(bgColor) can also be called only once from love.load.

To summarize all this info - move all unnesessary stuff from love.draw & love.update to other events.


4. You don't need setBorder at all. Again, love.graphics.setLineWidth goes to love.load and change loop in love.draw to:
EDIT: I'm wrong here.

Code: Select all

	for i=1,gridSize do
		for j=1,gridSize do
			if player[i][j] == 1 then love.graphics.setColor(tileColor)
			else love.graphics.setColor(bgColor)
			end
			x, y, w, h = gx+(i-1)*(gs/gridSize),gy+(j-1)*(gs/gridSize),gs/gridSize,gs/gridSize
			love.graphics.rectangle("fill", x, y, w, h)
			love.graphics.setColor(txtColor)
			love.graphics.rectangle("line", x, y, w, h)
		end
	end
5. Study and make use of canvases. This way you don't need to redraw each cell (until resize occures).

EDIT: I can also recommend never use "magic numbers" like 800, 600 right in the code. Use variables with meaningful names. It applies to any programming language.
1. For some stupid reason, I wasn't aware of love.graphics.setFont(). Thanks for reminding me.

2. Actually, love.resize() is only called when love.window.setMode() is set to an unsupported width/height. So I have to leave it as is, unfortunately.

3 & 4. More stupid mistakes of mine. Thanks again. :D

5. I won't implement a canvas for this little project as it would involve reworking a lot (especially since I have no idea how to use canvases yet). I'd rather wait until my next project so that I may learn it properly.

The changes have been made and the attached game has been updated. Thanks for trying it!
pel
Prole
Posts: 28
Joined: Mon Aug 17, 2015 6:48 am

Re: SquareZ

Post by pel »

How do you play?

When I press F1, it crashes:

Code: Select all

Error

main.lua:106  attempt to call field 'showMessageBox' (a nil value)

Traceback

main.lua: 106 in function <main.lua:97>
[C]: in function 'xpcall'
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: SquareZ

Post by zorg »

pel wrote:main.lua:106 attempt to call field 'showMessageBox' (a nil value)
Use 0.9.2, since the message box was added in that release of löve.
Edit: Tested and worksforme on win7... dunno then.
Last edited by zorg on Fri Sep 11, 2015 12:48 pm, edited 1 time in total.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
pel
Prole
Posts: 28
Joined: Mon Aug 17, 2015 6:48 am

Re: SquareZ

Post by pel »

Use 0.9.2, since the message box was added in that release of löve.
I am. 0.9.2 for OS X Yosemite.
Xyore
Prole
Posts: 6
Joined: Thu Oct 09, 2014 11:40 pm

Re: SquareZ

Post by Xyore »

pel wrote:
Use 0.9.2, since the message box was added in that release of löve.
I am. 0.9.2 for OS X Yosemite.
Well, I just tested it on a Mac laptop with the mac build which can be found here: http://xyore.itch.io/squarez

Feel free to try that one.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests