Adventures of Barnabus! [T.A.O.T.R.T.W.G.E.]

Show off your games, demos and other (playable) creations.
User avatar
Petunien
Party member
Posts: 191
Joined: Fri Feb 03, 2012 8:02 pm
Location: South Tyrol (Italy)

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

Post by Petunien »

Sure, "9" stands for the last block. I forgot to say that.
But both solutions are equal regarding the execution speed, or?
"Docendo discimus" - Lucius Annaeus Seneca
User avatar
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.

Post 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.
Help us help you: attach a .love.
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

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

Post 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.
User avatar
Petunien
Party member
Posts: 191
Joined: Fri Feb 03, 2012 8:02 pm
Location: South Tyrol (Italy)

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

Post 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.
"Docendo discimus" - Lucius Annaeus Seneca
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

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

Post 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
User avatar
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.

Post 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.
Help us help you: attach a .love.
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

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

Post by coffee »

Robin wrote: EDIT: don't listen to coffee.
No please, don't lol. It mislead it for #. Sorry to both
User avatar
Petunien
Party member
Posts: 191
Joined: Fri Feb 03, 2012 8:02 pm
Location: South Tyrol (Italy)

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

Post 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. :)
"Docendo discimus" - Lucius Annaeus Seneca
User avatar
Banoticus
Citizen
Posts: 60
Joined: Wed Apr 04, 2012 4:01 pm
Location: London

THANKS SO MUCH!

Post 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 192 times
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: THANKS SO MUCH!

Post 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?
Last edited by coffee on Wed Jul 11, 2012 5:12 pm, edited 1 time in total.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 179 guests