Sure, "9" stands for the last block. I forgot to say that.
But both solutions are equal regarding the execution speed, or?
Adventures of Barnabus! [T.A.O.T.R.T.W.G.E.]
Re: T.A.O.T.R.T.W.G.E.
"Docendo discimus" - Lucius Annaeus Seneca
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: T.A.O.T.R.T.W.G.E.
I myself would use:
numBlocks would be 9 in this case, or as coffee said, #someTableThatKeepsTrackOfTheBlocks.
EDIT:
If you find yourself thinking about execution speed, stop right away. Until and unless it's an actual problem, it's not something you should worry or think about.
Code: Select all
function love.mousepressed(x, y, button)
if button == "wu" then
selectedBlock = selectedBlock % numBlocks + 1
elseif button == "wd" then
selectedBlock = (selectedBlock - 2) % numBlocks + 1
end
end
EDIT:
For all intents and purposes, yes.Petunien wrote:But both solutions are equal regarding the execution speed, or?
If you find yourself thinking about execution speed, stop right away. Until and unless it's an actual problem, it's not something you should worry or think about.
Help us help you: attach a .love.
Re: T.A.O.T.R.T.W.G.E.
Checking the table should be slower a bit. Not the problem, you must do it all the times everywhere. You didn't nothing wrong but in that way you are stick only to that number of blocks. With mine or robin's solution you can add/remove blocks at anytime without worries or have any number of blocks you want. More flexible. Davidbot would then have someday a problem like that.Petunien wrote:Sure, "9" stands for the last block. I forgot to say that.
But both solutions are equal regarding the execution speed, or?
Re: T.A.O.T.R.T.W.G.E.
@Robin
Could you please explain the following part of your code?
What does the "%" stand for?
I don't know after what I have to google.
Of course, in this magnitude of games, execution speed, efficiency etc. isn't that important.
But when I was trying around the Minimax-Algorithm, speed was not a thing to look away of it.
And sorry for filling this thread with my offtopic posts. Please delete them in case of inconvenience.
Could you please explain the following part of your code?
What does the "%" stand for?
I don't know after what I have to google.
Code: Select all
selectedBlock [b]%[/b] numBlocks + 1
Hmm, I remember you said it already once a time to me.Robin wrote: For all intents and purposes, yes.
If you find yourself thinking about execution speed, stop right away. Until and unless it's an actual problem, it's not something you should worry or think about.
Of course, in this magnitude of games, execution speed, efficiency etc. isn't that important.
But when I was trying around the Minimax-Algorithm, speed was not a thing to look away of it.
And sorry for filling this thread with my offtopic posts. Please delete them in case of inconvenience.
"Docendo discimus" - Lucius Annaeus Seneca
Re: T.A.O.T.R.T.W.G.E.
It's basic Lua. %nameoftable gives the count of elements a table have. You should check it. It's unvaluable in table operations.Petunien wrote: What does the "%" stand for?
http://lua-users.org/wiki/TablesTutorial
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: T.A.O.T.R.T.W.G.E.
% is the modulo operator, a.k.a. the remainder after division.Petunien wrote:@Robin
Could you please explain the following part of your code?
What does the "%" stand for?
Thus:
Code: Select all
0 % 9 == 0
1 % 9 == 1
2 % 9 == 2
5 % 9 == 5
8 % 9 == 8
9 % 9 == 0
10 % 9 == 1
11 % 9 == 2
17 % 9 == 8
18 % 9 == 0
EDIT: don't listen to coffee.
Help us help you: attach a .love.
Re: T.A.O.T.R.T.W.G.E.
No please, don't lol. It mislead it for #. Sorry to bothRobin wrote: EDIT: don't listen to coffee.
Re: T.A.O.T.R.T.W.G.E.
Ok, I think I have understood.
Thank you (both).
I would say, a moderator could, if the thread creator wants it, delete all of the posts except Robin's solution.
The origin of that thread was after all The Adventure of The Red Thing With Green Eyes.
Thank you (both).
I would say, a moderator could, if the thread creator wants it, delete all of the posts except Robin's solution.
The origin of that thread was after all The Adventure of The Red Thing With Green Eyes.
"Docendo discimus" - Lucius Annaeus Seneca
THANKS SO MUCH!
Thank you so much for helping me with that scrolling feature, especially robin for the best answer. I have now added it to the game and it is working as smoothly as ever.
Here is a zipped version of the folder with the game inside:
Here is a zipped version of the folder with the game inside:
Re: THANKS SO MUCH!
The menu is working smoothly but I can't say the same of that "flickering" moving cloud and other moving things. I'm getting only 21FPS thing what only happens in that heavy LOVE demanding technical demos. You should check for something wrong in your code.Banoticus wrote:working as smoothly as ever.
EDITED: LOL you should remove your internal messages from LOVE. Or don't. Was hilarious!
All
you just changed the layering. You lazy bastard.
Well, do you have any suggections on blocks? Do you?
Last edited by coffee on Wed Jul 11, 2012 5:12 pm, edited 1 time in total.
Who is online
Users browsing this forum: No registered users and 2 guests