Better Snake [1.0]

Show off your games, demos and other (playable) creations.
Post Reply
AngusWP
Prole
Posts: 9
Joined: Mon Jan 22, 2018 11:35 pm

Better Snake [1.0]

Post by AngusWP »

BetterSnake is my spin on the game snake. I started with Lua and Love2D today, and looked up a snake tutorial. From there I just modified the game and gave it more features. You can look at the code for this if you want, it's not very advanced. The reason I am posting here is to ask: Are there any really informative tutorials on Love2D? I have previously coded in Java and I want to learn Lua as it seems to be a lot easier and just as fun.

https://github.com/AngusWP/bettersnake

Another thing I want to ask - when I tried to run main.lua inside a package, it wouldn't run. I am used to packages through Java but what is the normal way to structure Lua code, and if there is no package system is there a better way to keep everything organized and not just in one huge class?

Another thing, I wanted to add a game icon but I can't convert my image into image data, does anyone know how to make this work?

Code: Select all

icon = love.graphics.newImage("images/snake_icon.png");
love.window.setIcon(icon:getData());
    
Thanks for reading my post! If you would recommend any game projects that don't take too much work but will teach me more about Lua, just let me know. I want to learn!
User avatar
Sir_Silver
Party member
Posts: 286
Joined: Mon Aug 22, 2016 2:25 pm
Contact:

Re: Better Snake [1.0]

Post by Sir_Silver »

I can't speak from experience, but people have recommended checking out sheepolution for love2d specific tutorials: http://sheepolution.com/learn/book/0

With regards to the code you've written, works perfectly fine for me. Is your snake_icon.png image inside of your images folder?
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Better Snake [1.0]

Post by zorg »

You should load in the image file as an ImageData instead, since you cannot convert Images to ImageData anymore; that way you can pass the ImageData to setIcon. (Use love.image.newImageData)

Also, define packages, since i fail to understand what you mean by keeping everything organized in one "class"; don't use classes? or look at kikito's library tutorial, where he details how to isolate code into separate files: http://kiki.to/blog/2014/03/30/a-guide- ... a-modules/
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.
AngusWP
Prole
Posts: 9
Joined: Mon Jan 22, 2018 11:35 pm

Re: Better Snake [1.0]

Post by AngusWP »

Sir_Silver wrote: Tue Jan 23, 2018 4:17 am With regards to the code you've written, works perfectly fine for me. Is your snake_icon.png image inside of your images folder?
I changed it to image data, and the code runs fine but the actual window does not show it. I googled it and it turns out sometimes there is an issue where other people can see it but the person who wrote it can't? This could be a bug with Zero Brain Studios or something.
AngusWP
Prole
Posts: 9
Joined: Mon Jan 22, 2018 11:35 pm

Re: Better Snake [1.0]

Post by AngusWP »

zorg wrote: Tue Jan 23, 2018 8:34 am Also, define packages, since i fail to understand what you mean by keeping everything organized in one "class"; don't use classes? or look at kikito's library tutorial, where he details how to isolate code into separate files: http://kiki.to/blog/2014/03/30/a-guide- ... a-modules/
Yeah classes are a Java thing sorry, I meant I don't want to have everything in one .lua file and want to be able to keep it organized in different .lua files.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests