I changed the name of the folder to VerySimpleSpaceGame that is probably the reason for the run problem. I make a variable global if it is used in more than one function. What I guess I'm forgetting to do because I'm new to Lua is to use the local keyword everywhere I should. I'll need to spiff it up a bit. It does have a nice feel to it and I think I'm doing a decent job organizing the code and keeping it clean and simple. ThanksBobble68 wrote: ↑Wed Dec 27, 2023 9:01 pm Something seems to be up with the way you've packaged your game - normally if you have Love2D installed, you should be able to run the .love file directly. I could only do that once I unzipped it and repackaged it myself.
What method are you using for this?
Other than that, seems to be coming along nicely! My other piece of feedback is that you seem to be using a good deal of global variables, rather than local ones. I'm not one of those people who thinks globals should be illegal, but I will say they should be used sparingly - locals are a little faster, and are less likely to cause you issues down the line. If you have an issue that affects one of your globals, it will be much more difficult to track it down, especially if it's the result of a typo.
Started My Very First Love2d Game
Re: Started My Very First Love2d Game
Re: Started My Very First Love2d Game
Another long day and some nice progress. All that remains to be done now to have a pre alpha but playable game is to write the computer players AI. As it is now the human player can send ships to planets in range and conquer the galaxy with no opposition. Napoleon, Hitler and P___n sure could of used someone like me. lol Sorry, poor joke. Anyway just click on the/a medium blue star and then on any other mb star or enemy that is in range and send some ships. The send ships panel is not complete yet so please give me a pass on that. Remember, escape exits and n starts a new 'game'. Well not quite a game yet but getting there!
- Attachments
-
- VerySimpleSpaceGame.love
- (5.68 KiB) Downloaded 231 times
Re: Started My Very First Love2d Game
Probably incorrectly packaged:
Code: Select all
Error
[love "boot.lua"]:321: No code to run
Your game might be packaged incorrectly.
Make sure main.lua is at the top level of the zip.
Traceback
[love "callbacks.lua"]:228: in function 'handler'
[C]: in function 'error'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: Started My Very First Love2d Game
I use 7-Zip to zip folder VerySimpleSpaceGame. In that folder are all the source files:dusoft wrote: ↑Thu Dec 28, 2023 11:04 am Probably incorrectly packaged:Code: Select all
Error [love "boot.lua"]:321: No code to run Your game might be packaged incorrectly. Make sure main.lua is at the top level of the zip. Traceback [love "callbacks.lua"]:228: in function 'handler' [C]: in function 'error' [C]: in function 'xpcall' [C]: in function 'xpcall'
colors.lua
draw.lua
globals.lua
initiate.lua
main.lua
update.lua
utils.lua
That produces file VerySimpleSpaceGame.zip
I change the .zip to .love as instructed and attach it.
So what am I doing wrong?
So maybe I should just zip the files and not the folder? I'll try that. Okay done.
Thanks
- Attachments
-
- VerySimpleSpaceGame.love
- No folder this time
- (5.26 KiB) Downloaded 202 times
Re: Started My Very First Love2d Game
There are always alternatives to using globals - one I would recommend is using requires to replace them (I've only just begun using this method myself, I wish I had been using it earlier).kingnoob wrote: ↑Wed Dec 27, 2023 10:37 pm
I make a variable global if it is used in more than one function. What I guess I'm forgetting to do because I'm new to Lua is to use the local keyword everywhere I should. I'll need to spiff it up a bit. It does have a nice feel to it and I think I'm doing a decent job organizing the code and keeping it clean and simple. Thanks
Local variables within the same module can be accessed by multiple functions, for example:
Code: Select all
--donuts.lua
local donuts = 1000
function getDonuts()
return donuts
end
function eatDonuts()
donuts = 0
end
--main.lua
require("donuts")
print(getDonuts())
eatDonuts()
print(getDonuts())
So the require method I mentioned before works like this - the require function can return values from the target module. Since tables are passed by reference, this means you can essentially create global variables where you can control the scope (scope is the term for where variables are and aren't valid).
Code: Select all
--colours.lua
local colour = {}
colour.red = {1, 0, 0}
colour.green = {0, 1, 0}
colour.blue = {0, 0, 1}
return colour
--main.lua
local colour = require("colours")
love.graphics.setBackgroundColor(colour.green)
Sorry that was a bit of a lecture, just use what works for you, though its best to keep these things in mind.
That seems to have fixed it! Love will look for main at the bottom level, so an extra folder was confusing it.
Dragon
Re: Started My Very First Love2d Game
Very simple space game indeed. It took me a minute to understand what a player should be doing. Dragging a line would help in addition to clicks. Also it's not clear what the starting planet is and also why in range says "NA" (once one identifies their home planet, it's alright).
Well done. I like the planet names.
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: Started My Very First Love2d Game
Thanks!dusoft wrote: ↑Thu Dec 28, 2023 3:42 pmVery simple space game indeed. It took me a minute to understand what a player should be doing. Dragging a line would help in addition to clicks. Also it's not clear what the starting planet is and also why in range says "NA" (once one identifies their home planet, it's alright).
Well done. I like the planet names.
NA means Not Applicable because one's own stars are always in range (slipstream projectors at both stars, lol). this though is temporary until more functionality is added.
Dragging a line is just a way of showing that selection is in progress. But I should have mentioned that. Soon I'll make a readme that can be updated as progress is made. The game (it is a game now) starts off paused. While not in selection mode paused is toggled by clicking the right mouse button on empty space. Sometimes it is just too hectic not to pause the game. And orders can be entered while paused. I'll make a follow up post shortly about the changes. Maybe blinking the human's home planet while paused will help it to be found. It is not easy coming up with 200 star names. Some of them I made up out of thin air,lol.
Re: Started My Very First Love2d Game
I will study this and spiff up the code when I understand it better. Though most of the globals are used in more than one module/file. I just need to study it for awhile. Thanks
Re: Started My Very First Love2d Game
I meant having an option to drag a line from one planet to another as an alternative to clicking first and clicking second. I tried that, but it didn't work and it took me a second to find out I can click on a planet and then another and that initiates transfer.
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: Started My Very First Love2d Game
Houston we have liftoff! It is a real game now!! It is still pre alpha or maybe even pre pre alpha but it is playable.
The AI is the simplest (and stupidest) AI I can make that is just above random. It can and will give one grief at times.
The game starts off paused. Toggle paused by right clicking on open space while not in any gui mode.
I can't play very long because my aio cpu cooler is on the fritz and the cpu is getting hot while running the game. So it seems okay but I haven't tested it like it should be tested. This is probably a good time to add a save file.
The biggest change to sending ships is ships can be sent to any enemy star that is in range of any of the players other stars. Well it is a game rather than a simulation so i'll be taking many liberties with reality to keep the game simple.
Remember, escape exits and n starts a new game. I just realized the fleets are not cleared on pressing n so that might be a problem. Starting a new game while initially paused would be okay if one does not like their starting position.
readme coming soon. Even very simple space games require a lot of work. I hope someone likes my game.
The AI is the simplest (and stupidest) AI I can make that is just above random. It can and will give one grief at times.
The game starts off paused. Toggle paused by right clicking on open space while not in any gui mode.
I can't play very long because my aio cpu cooler is on the fritz and the cpu is getting hot while running the game. So it seems okay but I haven't tested it like it should be tested. This is probably a good time to add a save file.
The biggest change to sending ships is ships can be sent to any enemy star that is in range of any of the players other stars. Well it is a game rather than a simulation so i'll be taking many liberties with reality to keep the game simple.
Remember, escape exits and n starts a new game. I just realized the fleets are not cleared on pressing n so that might be a problem. Starting a new game while initially paused would be okay if one does not like their starting position.
readme coming soon. Even very simple space games require a lot of work. I hope someone likes my game.
- Attachments
-
- VerySimpleSpaceGame.love
- (5.77 KiB) Downloaded 254 times
Who is online
Users browsing this forum: No registered users and 0 guests