If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Sliding Tile Puzze
11 posts
• Page 1 of 2 • 1, 2
Sliding Tile Puzze
This is my little vacation Ruby excercise.
Download only if you need to kill time and have absolutely nothing else to do.

- Attachments
-
slidingTilePuzzle.fsm
- (959.1 KiB) Downloaded 1122 times
Last edited by martinvicanek on Tue Feb 09, 2016 2:33 pm, edited 1 time in total.
-
martinvicanek - Posts: 1334
- Joined: Sat Jun 22, 2013 8:28 pm
Re: Sliding Tile Puzze
Crashed FS on load..3.06 (Pebble)...twice.....What version is it built with?
BV MUSIC SYDNEY AUSTRALIA..Songwriting and Software development
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
- billv
- Posts: 1158
- Joined: Tue Aug 31, 2010 3:34 pm
- Location: Australia
Re: Sliding Tile Puzze
Very nice! I remember I had a game like this when I was a kid 
works fine in 3.0.8

works fine in 3.0.8
- adamszabo
- Posts: 667
- Joined: Sun Jul 11, 2010 7:21 am
Re: Sliding Tile Puzze
Sorry, billv. I am using 3.0.8. I have a suspicion what might have caused the crash in an earlier version. Try the updated fsm in the original post.
-
martinvicanek - Posts: 1334
- Joined: Sat Jun 22, 2013 8:28 pm
Re: Sliding Tile Puzze
Nice 3-d frame !
won't even begin to start playing the game for obvious reasons
won't even begin to start playing the game for obvious reasons

- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: Sliding Tile Puzze
This version runs with 3.0.6
Well done!
There are a few things to optimize, but not that much. The pens, brushes and colors are assigned to variables, which makes it easier to select the correct ones. But it also allows you to define them in the initializion method instead of the draw method, where they are defined on each draw call. By defining them just once, the garbage collector has much less work to do, which means less cpu usage.
The condition of an if clause always resolves to true or false, so it is valid to write
Once again you use indentation (which is more important than people might think). If you now could also get rid of the old-school-behavior of using as less spaces as possible, your code would be perfect!
Well done!
There are a few things to optimize, but not that much. The pens, brushes and colors are assigned to variables, which makes it easier to select the correct ones. But it also allows you to define them in the initializion method instead of the draw method, where they are defined on each draw call. By defining them just once, the garbage collector has much less work to do, which means less cpu usage.
The condition of an if clause always resolves to true or false, so it is valid to write
- Code: Select all
if @mybool
#do something if @mybool is set to true
end
Once again you use indentation (which is more important than people might think). If you now could also get rid of the old-school-behavior of using as less spaces as possible, your code would be perfect!
- Code: Select all
a=(b*c)/d-e^^f #old way
a = (b * c) / d - e^^f #better readable
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Sliding Tile Puzze
Thanks Martin...yeh, all good now on 3.06.
Nice work.
Nice work.
BV MUSIC SYDNEY AUSTRALIA..Songwriting and Software development
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
- billv
- Posts: 1158
- Joined: Tue Aug 31, 2010 3:34 pm
- Location: Australia
Re: Sliding Tile Puzze
Fair enough, and you made this point earlier. We really need this facepalm emoticon.tulamide wrote:The pens, brushes and colors [...] define them in the initializion method instead of the draw method, where they are defined on each draw call.

tulamide wrote:If you now could also get rid of the old-school-behavior of using as less spaces as possible, your code would be perfect!
- Code: Select all
a=(b*c)/d-e^^f #old way
a = (b * c) / d - e^^f #better readable
I use spaces around "+" and "-", but not around "*" or "/" as they have stronger binding. For me it is easier to see that
- Code: Select all
a^2 + 2*a*b + b^2

-
martinvicanek - Posts: 1334
- Joined: Sat Jun 22, 2013 8:28 pm
Re: Sliding Tile Puzze
martinvicanek wrote:I use spaces around "+" and "-", but not around "*" or "/" as they have stronger binding. For me it is easier to see thatis a three term expression. At least we agree that the exponent should not be detached from its base. (a ^ 2 - ouch!).
- Code: Select all
a^2 + 2*a*b + b^2
It's not so much about personal preference. Pretty much all programming languages, at least the ones I know, have style guides. This is to agree on a common way to write code, so that it is easily interchangeable while all programmers recognize the code fast and easy. Ruby has such a style guide as well, and it says:
Use spaces around operators, after commas, colons and semicolons, around { and before }.
- Code: Select all
sum = 1 + 2
a, b = 1, 2
1 > 2 ? true : false; puts "Hi"
[1, 2, 3].each { |e| puts e }
Here are two versions of the style guide (they are the same, but I don't know which one will be updated more regularly (probably the second link):
https://github.com/styleguide/ruby
https://github.com/airbnb/ruby
But we are in the same boat. There are some things that I still need to get used to (like using parantheses with methods and indenting when only as deep as case) and even some that I don't agree to (the style guide tells me that "and", "or" and "not" are banned and I should use &&, || and ! instead. I disagree extremely on this, because Ruby's goal is to be readable as easy as possible. Using strange signs instead of clear words doesn't help towards that goal)
The more we get used to the style guide, the easier it is for us to work on shared projects. That's why I pointed to it so strong

"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Sliding Tile Puzze
We all learn from these posts.
Thank-you Gentlemen
Thank-you Gentlemen

- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
11 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 29 guests