Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Simple 15 Puzzle Game  (Read 12080 times)

0 Members and 1 Guest are viewing this topic.

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Simple 15 Puzzle Game
« on: January 14, 2016, 10:27:56 pm »
i have made simple puzzle game, it is quite simple and easy, i have done it before but in win32 console. when i start learning C++,

GamePlay:
the game is simple has only one button "scramble" it does shuffle the numbers and start from beginning, and user may use arrow keys to move in the only space available in the game. i didn't add time limit. it's a bit harder by itself.

finially i'm able to complete the puzzle. here a demo of game play
http://www.youtube.com/watch?v=qArw1fOMP04
« Last Edit: April 13, 2020, 08:03:01 pm by Mortal »

Hapax

  • Hero Member
  • *****
  • Posts: 3344
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Simple 15 Puzzle Game
« Reply #1 on: January 15, 2016, 01:12:25 am »
This game is easy  :P

Does your scramble place the number in a random order or does it move them randomly multiple times to shuffle/scramble them?
If they're in a random order, 50% of the time, the puzzle is unsolvable  :-X

p.s. I meant that the game is easy to play and win; it's not a comment on the creation of the program!
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: Simple 15 Puzzle Game
« Reply #2 on: January 15, 2016, 10:47:59 am »
This game is easy  :P
nah, i couldn't finish it, i just moving number peaces around, like a dumb guy who dont know what he doing. lol, i'm sure there are some rolls need to apply in order to complete it.


Does your scramble place the number in a random order or does it move them randomly multiple times to shuffle/scramble them?
If they're in a random order, 50% of the time, the puzzle is unsolvable  :-X

yeah, scramble is tricky part i did both, i had to create indices array to shuffle it and place tile peaces in random order based on indices values.

p.s. I meant that the game is easy to play and win; it's not a comment on the creation of the program!
thanks for complement, actually it is indeed easy to make but harder to complete  :)

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: Simple 15 Puzzle Game
« Reply #3 on: January 15, 2016, 01:42:14 pm »
Update

since there is only one free place that tile peaces can fit in i added mouse click for easing the game control, the user can move tile speaces either with arrow keys or by mouse click
« Last Edit: January 15, 2016, 01:45:25 pm by MORTAL »

Hapax

  • Hero Member
  • *****
  • Posts: 3344
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Simple 15 Puzzle Game [Finished]
« Reply #4 on: January 16, 2016, 12:13:20 am »
Most reliable way to scramble would to just move in a random direction many times.

Does your clicking require one tile at a time to move or can you click multiple tiles away? e.g. In your image, can you click "11" to move them both or do you need to click "7" first and then "11"?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: Simple 15 Puzzle Game [Finished]
« Reply #5 on: January 16, 2016, 01:30:22 am »
Most reliable way to scramble would to just move in a random direction many times.
good point, yeah that only what it needs to shuffle the tile peaces instead of Reconstruction the whole tiles again. i have edit repo.
thanks alot Hapax  :)


Does your clicking require one tile at a time to move or can you click multiple tiles away? e.g. In your image, can you click "11" to move them both or do you need to click "7" first and then "11"?
it moves only one tile for each mouse click. i believe multiple movements can be done by mouse clicked but how this will applied to arrow keys, i mean, how to select group of tiles by arrow keys?

Hapax

  • Hero Member
  • *****
  • Posts: 3344
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Simple 15 Puzzle Game
« Reply #6 on: January 16, 2016, 02:34:01 am »
You don't need to add this functionality to key controls as you can easily press the key multiple times. Clicking on a tile that is multiple tiles away from the hole/space, though, gives the impression that they are trying to move that specific tile.

If you want to include a way to "slide" multiple tiles with the keys (choose either two tiles or the rest of the row to the end), you could do that if shift is pressed when you press the arrow key. This is optional, of course, and totally up to you if you want this sort of thing  ;D
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: Simple 15 Puzzle Game
« Reply #7 on: January 16, 2016, 02:58:02 am »
If you want to include a way to "slide" multiple tiles with the keys (choose either two tiles or the rest of the row to the end), you could do that if shift is pressed when you press the arrow key. This is optional, of course, and totally up to you if you want this sort of thing  ;D
i guess you already know my answer. lol

i have no idea how to implement it, but it is really worth to try. 

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: Simple 15 Puzzle Game
« Reply #8 on: January 16, 2016, 07:01:48 pm »
Update

  • fixed bug where some tiles not shuffle properly
  • effectively generate randomness
  • mimic std::shuffle's functionality, now tiles shuffled correctly

i'm so excited of being able to finish a game in two days,  :) , that a world record for me. gotta celebrate to night

cheers
« Last Edit: January 16, 2016, 07:35:52 pm by MORTAL »

Elias Daler

  • Hero Member
  • *****
  • Posts: 599
    • View Profile
    • Blog
    • Email
Re: Simple 15 Puzzle Game [Finished]
« Reply #9 on: January 17, 2016, 08:23:00 am »
It's pretty cool that you make so much stuff in such short amount of time. Great job :)
Tomb Painter, Re:creation dev (abandoned, doing other things) | edw.is | @EliasDaler

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: Simple 15 Puzzle Game [Finished]
« Reply #10 on: January 17, 2016, 11:42:33 am »
It's pretty cool that you make so much stuff in such short amount of time. Great job :)
thanks Elias, i appreciate so much

Hapax

  • Hero Member
  • *****
  • Posts: 3344
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Simple 15 Puzzle Game [Finished]
« Reply #11 on: January 17, 2016, 11:56:44 pm »
Good to see a video up of it in action! Also good to see that you won the game! (told you it was easy  :P )

I still think you should implement moving multiple tiles with the mouse  ::)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: Simple 15 Puzzle Game [Finished]
« Reply #12 on: January 18, 2016, 07:40:41 pm »
Good to see a video up of it in action! Also good to see that you won the game! (told you it was easy  :P )

thanks Hapax, yeah you are right, but it become easy only after i learned from 11 years boy on youtube about how to play it. ;D

I still think you should implement moving multiple tiles with the mouse  ::)
i have implemented after struggle about array indexes and swapping them. it seems okay, hopefully it is free of hidden bugs  :-\

here a Demo:

Hapax

  • Hero Member
  • *****
  • Posts: 3344
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Simple 15 Puzzle Game
« Reply #13 on: January 19, 2016, 04:24:45 pm »
If you wanted a simple way to implement it (performance on this sort of game would not be affected), you could simply get the tile clicked on and then:
1) work out if it's on the same horizontal or vertical line as the space,
2) calculate how many spaces away from the space, and
3) loop moving one space in the correct direction.

I'm glad you added it, though. It makes a big difference to the playability with the mouse!
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: Simple 15 Puzzle Game
« Reply #14 on: January 19, 2016, 06:03:04 pm »
If you wanted a simple way to implement it (performance on this sort of game would not be affected), you could simply get the tile clicked on and then:
1) work out if it's on the same horizontal or vertical line as the space,
2) calculate how many spaces away from the space, and
3) loop moving one space in the correct direction.
i wished i had your comment earlier, it would save me time that i spent it on how to move tile peaces efficiently. coincidentally i just did this mechanism in the game

I'm glad you added it, though. It makes a big difference to the playability with the mouse!
thanks, i'm totally agree with that