## Tic Tac Toe [WIP] - First Game

Show off your games, demos and other (playable) creations.
MorbusKobold
Prole
Posts: 3
Joined: Fri Jan 15, 2021 3:02 pm

### Tic Tac Toe [WIP] - First Game

Tic Tac Toe - Version 1.2

I've messing around with Love Lua for some Time now, and just wanted to get some Feedback on my Coding Style (Hobby Programmer all self taught).
Here is my first Submission to the Community. It's a simple 2D Clone of TicTacToe, nothing to complicated.
All Libraries are written from Scratch.

collision.lua used this website: https://2dengine.com/?p=intersections , i've added some stuff and functions.

Bord.lua, Patterns.lua and Helper.lua aren't used and were used in older Versions.

No AI yet and the Options Menu isnt functioning.

Have fun. First Post.

Morbus Kobold.
Attachments
TicTacToeV1.2.love
darkfrei
Party member
Posts: 217
Joined: Sat Feb 08, 2020 11:09 pm

### Re: Tic Tac Toe [WIP] - First Game

How to start the game with mouse only?
sphyrth
Party member
Posts: 258
Joined: Mon Jul 07, 2014 11:04 am
Contact:

### Re: Tic Tac Toe [WIP] - First Game

For a self-taught programmer, that as very clean and readable code. You seem to be fluent in any language you study.

My suggestions will sacrifice some of that cleanness for better coding practices.
#1 - There some parts that should make use of love.update. Take menu.update() for an example.

Code: Select all

function love.update()
end
end
...
function love.draw()
...
elseif game.state == "game" then
...
end
...
end

#2 - I'm having trouble suggesting something about your usage of sxBackground, and syBackground. I know what they're for, but I'm too lazy to think of a solution that uses local variables and at the same time not doing it in love.draw().

#3 - I've only recently adjusted from using only dots(.) to semi-colons(:) for tables that use themselves in their functions.
For example, turn this:

Code: Select all

function menu.update()
end
...
end

Into something like this:

Code: Select all

function menu:update() -- or menu.update(self), but you'll call it as menu:update() anyway
if self.entry < 1 then
self.entry = 1
elseif self.entry > #self.entries then
self.entry = #self.entries
end
...
end

darkfrei
Party member
Posts: 217
Joined: Sat Feb 08, 2020 11:09 pm

### Re: Tic Tac Toe [WIP] - First Game

sphyrth wrote: Fri Jan 15, 2021 11:43 pm #3 - I've only recently adjusted from using only dots(.) to semi-colons(:) for tables that use themselves in their functions.
How to copy such objects with functions without metatables?
sphyrth
Party member
Posts: 258
Joined: Mon Jul 07, 2014 11:04 am
Contact:

### Re: Tic Tac Toe [WIP] - First Game

darkfrei wrote: Sat Jan 16, 2021 11:55 am How to copy such objects with functions without metatables?
I'm not really a good source for an answer to this, but I currently use normal tables.

Code: Select all

function newObj()
local object = {}

object.sample_var2 = 'blah'

function object:sampleFunction()
--
end

return object
end

Now, I just call that function.

Code: Select all

object1 = newObj()
object2 = newObj()
objectN = newObj()


### Who is online

Users browsing this forum: No registered users and 15 guests