Page 2 of 10

Re: T.A.O.T.R.T.W.G.E.

Posted: Wed Jul 11, 2012 3:45 pm
by Petunien
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.

Posted: Wed Jul 11, 2012 3:46 pm
by Robin
I myself would use:

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
numBlocks would be 9 in this case, or as coffee said, #someTableThatKeepsTrackOfTheBlocks.

EDIT:
Petunien wrote:But both solutions are equal regarding the execution speed, or?
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.

Re: T.A.O.T.R.T.W.G.E.

Posted: Wed Jul 11, 2012 3:54 pm
by coffee
Petunien wrote:Sure, "9" stands for the last block. I forgot to say that.
But both solutions are equal regarding the execution speed, or?
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.

Re: T.A.O.T.R.T.W.G.E.

Posted: Wed Jul 11, 2012 3:59 pm
by Petunien
@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.

Code: Select all

selectedBlock [b]%[/b] numBlocks + 1
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.
Hmm, I remember you said it already once a time to me. :)
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.

Re: T.A.O.T.R.T.W.G.E.

Posted: Wed Jul 11, 2012 4:06 pm
by coffee
Petunien wrote: What does the "%" stand for?
It's basic Lua. %nameoftable gives the count of elements a table have. You should check it. It's unvaluable in table operations.
http://lua-users.org/wiki/TablesTutorial

Re: T.A.O.T.R.T.W.G.E.

Posted: Wed Jul 11, 2012 4:08 pm
by Robin
Petunien wrote:@Robin
Could you please explain the following part of your code?
What does the "%" stand for?
% is the modulo operator, a.k.a. the remainder after division.

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
etc.

EDIT: don't listen to coffee.

Re: T.A.O.T.R.T.W.G.E.

Posted: Wed Jul 11, 2012 4:11 pm
by coffee
Robin wrote: EDIT: don't listen to coffee.
No please, don't lol. It mislead it for #. Sorry to both

Re: T.A.O.T.R.T.W.G.E.

Posted: Wed Jul 11, 2012 4:20 pm
by Petunien
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. :)

THANKS SO MUCH!

Posted: Wed Jul 11, 2012 4:59 pm
by Banoticus
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. :awesome:
Here is a zipped version of the folder with the game inside:
TAOTRTWGE.zip
The zip file (.luas in side)
(44.69 KiB) Downloaded 201 times

Re: THANKS SO MUCH!

Posted: Wed Jul 11, 2012 5:08 pm
by coffee
Banoticus wrote:working as smoothly as ever. :awesome:
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.

EDITED: LOL you should remove your internal messages from LOVE. Or don't. Was hilarious! :D
All
you just changed the layering. You lazy bastard.
Well, do you have any suggections on blocks? Do you?