Thanks for the clarification! I'm probably going to continue using cos/sin because its what I'm used to and I often need the angle anyways. I'll keep this in mind tho if I'm ever doing something very performance sensitive!pgimeno wrote: It's not a lot more efficient because these things are usually peanuts in comparison with the rest of the program, but it's one function call vs. three. Also, the square root used to take less cycles than trig functions; I haven't looked into the current status of things in more modern CPUs, though.
"Questions that don't deserve their own thread" thread
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: "Questions that don't deserve their own thread" thread
Computer science student and part time game dev! Currently working on Depths of Limbo!
Check out the game website DepthsOfLimbo.com!
And my personal website with all my projects evgiz.net!
Check out the game website DepthsOfLimbo.com!
And my personal website with all my projects evgiz.net!
Re: "Questions that don't deserve their own thread" thread
If you're not using love.thread, what would you be using?Jack Dandy wrote:I have another question for now, related to synchronization.
Is the only thing that instantiates new threads the "love.thread.newThread " command?
I'm asking this because of the following problem:
I think there are cases in which a certain function A is called before another function B is finished (The call isn't made from within B, but by another thing), and that it messes up some variables.
Should I worry about synchronization if I'm not using love.threads?
In love.thread, the threads don't share variables. You can't have functions that access the same variables. They can, however, share the same LÖVE data if you pass it among threads. From that standpoint, you don't need synchronization unless you are sharing LÖVE data and need it accessed orderly by each thread.
Not sure if that answers your question. I may have misunderstood it.
- Jack Dandy
- Prole
- Posts: 49
- Joined: Mon Sep 08, 2014 4:26 pm
Re: "Questions that don't deserve their own thread" thread
I just managed to solve the problem - It was related to something a bit different.
I was using Hump.Timer a bit carelessly and it caused 2 functions to change variables when.. they shouldn't have.
However, your answer also supplies me with good data for the future.
I don't need to worry about synchronization as long as I don't explicitly create new threads and share data between them.
I was using Hump.Timer a bit carelessly and it caused 2 functions to change variables when.. they shouldn't have.
However, your answer also supplies me with good data for the future.
I don't need to worry about synchronization as long as I don't explicitly create new threads and share data between them.
Re: "Questions that don't deserve their own thread" thread
What would be the best way to do a statistics save file? I have a few small casino games I'm trying to incorporate together and would like to have save-able stats between games, and plays. The file would be loaded at startup and saved after each round.
A: Serialize/de-serialize a table.
or B: Like a configuration file line by line.
A: Serialize/de-serialize a table.
Code: Select all
stats = {
money = 1000,
played = 0,
won = 0,
lost = 0,
blackjack = {
played = 0,
won = 0,
lost = 0,
profit = 0
},
holdem = {
played = 0,
won = 0,
lost = 0,
profit = 0
}
-- etc
}
Code: Select all
MONEY 1000
PLAYED 0
WON 0
LOST 0
BJPLAYED 0
BJWON 0
BJLOST 0
BJPROFIT 0
HOLDPLAYED 0
HOLDWON 0
HOLDLOST 0
HOLDPROFIT 0
--etc
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: "Questions that don't deserve their own thread" thread
I use a table. That way I keep all savable variables in one table and for saving I can just use a library to dump it all into a string and write it to a file, and to load it's as easy as just replacing the same table by loading it executed. (Where you use the parenthesis after the load() function like variable = love.filesystem.load(file)().)
Then you can set up default preferences by just putting an identical preferences.lua file in your project. That way if you haven't changed anything, Löve will load the included built-in prefs file, and once you change something and save in the same place, from then on Löve will load that instead. And you can "reset to factory defaults" by simply deleting the file.
This works for anything from a preferences file to a save game file.
Then you can set up default preferences by just putting an identical preferences.lua file in your project. That way if you haven't changed anything, Löve will load the included built-in prefs file, and once you change something and save in the same place, from then on Löve will load that instead. And you can "reset to factory defaults" by simply deleting the file.
This works for anything from a preferences file to a save game file.
Re: "Questions that don't deserve their own thread" thread
Thank you so much for the quick reply, it will surely help! I've been throwing this on the back burner for a while now, as I wasn't sure what was best.
-
- Prole
- Posts: 8
- Joined: Thu Oct 13, 2016 12:36 pm
Re: "Questions that don't deserve their own thread" thread
It appears the bug reports for canvas were out of date, the canvas seems to work fine. (width / static_size_virtual = scale_float)
Re: "Questions that don't deserve their own thread" thread
Just a quick question about nested tables, I have this:
I would assume that for msgbox.container.w, where w= screen.W (screen width) - msgbox.padding*2 that it would simply be equal to screen.W-10, since msgbox.padding = 10, but I receive and error that says:
I also tried moving padding outside the table and just named it padding, e.g. w = screen.W-padding, which worked fine, but then I would also get and error in msgbox.text, saying the same thing, so I'm certain it's a fault in my understanding of tables
Code: Select all
msgbox = {
padding = 10,
container = {
x = 10,
y = screen.H/2,
w = screen.W-msgbox.padding*2,
h = screen.H/5-msgbox.padding,
},
text = {
x = msgbox.container.x,
y = msgbox.container.y
},
}
Maybe I'm missing something here with nested tables, maybe one of you smarter people can give me a hand as to why I keep getting this?attempt to perform arithmetic on global 'padding' a nil value
I also tried moving padding outside the table and just named it padding, e.g. w = screen.W-padding, which worked fine, but then I would also get and error in msgbox.text, saying the same thing, so I'm certain it's a fault in my understanding of tables
Last edited by milk on Fri Oct 21, 2016 2:16 pm, edited 1 time in total.
Re: "Questions that don't deserve their own thread" thread
You can't access table until after it is created.
Who is online
Users browsing this forum: No registered users and 4 guests