android
  #1  
Old 02-22-2010, 11:14 AM
DanTheLegoMan DanTheLegoMan is offline
Junior Member
 
Join Date: Feb 2010
Posts: 38
Default Solitaire Version 1.2 Posted Feb 26th 2010

Solitaire

Complete implementation of this classic card game. The game will tell you if / when it becomes impossible to win.

Version 1.2

Fixed a bug in the save/load statistics that meant the bestTime was not saved properly
Added save/load game capability
Tweaked the graphics for the Diamonds

Notes:

When playing, press the Home Button to go to new menu that enables you to either Return (to the game), Save + Quit, start a New Game or Quit the application. If you have a game in progress, pressing 'New Game' or 'Quit' will count as a lose.

The save Game is automatically deleted after you load it.

Version 1.1

Improved graphics featuring some insect images for the J,Q,K cards taken from iconshock.com
Statistics are recorded to file (wins, loses, and best time)
Launching the application takes you to the menu

Version 1.0

No known issues. Using some kind of stylus makes it easier to move the cards around - but a finger will work if you are precise!

DanTheLegoMan
Attached Images
File Type: jpg Solitaire.jpg (12.9 KB, 249 views)
Attached Files
File Type: zip Solitaire.zip (91.9 KB, 1029 views)

Last edited by DanTheLegoMan; 02-26-2010 at 10:33 AM. Reason: New version
Reply With Quote

Advertisement [Remove Advertisement]

  #2  
Old 02-22-2010, 11:49 AM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,079
Default

I have never been good at this game, now I might get some practice =P

Wonder which is best, yours or the one made in the China competition

The icon is a bit boring, initial reaction, games look nice though ^^
Being rotated like this it might even be playable with mostly one hand, nice call.
In the future a game stats feature would be fun.
Also, maybe do something about the cards, I know it's hard to fit in all markings on them, but even the clothed cards look like 2s.

EDIT: Got to the no moves left screen. Might be good with an indication of the number of moves remaining, if having a limited amount. Also, why not have the start screen when you start the app also?

Also I'm not sure if it really does tell you when it is impossible to win, I've been staring at this thing for quite a while and can't find a possible move. But don't take my word for it, as I said, I'm not the best at this game.
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^

Last edited by Habhome; 02-22-2010 at 12:11 PM.
Reply With Quote

  #3  
Old 02-22-2010, 11:55 AM
blikbier's Avatar
blikbier blikbier is offline
Junior Member
 
Join Date: Feb 2010
Location: Netherlands
Posts: 98
Default

I love that game! Thanks a lot: D
Reply With Quote

  #4  
Old 02-22-2010, 12:40 PM
Tmd Tmd is offline
Junior Member
 
Join Date: Feb 2010
Posts: 15
Default

same as habhome i think i got to the point of no more possible moves but didn't get the notification in the game, but im not the best either.

The game works really nice though, maybe some sounds could be added in? thanks for taking the time to program =))
Reply With Quote

  #5  
Old 02-22-2010, 12:52 PM
MoePercent MoePercent is offline
Junior Member
 
Join Date: Feb 2010
Posts: 9
Default

great
Reply With Quote

  #6  
Old 02-22-2010, 01:19 PM
RobertsAccount's Avatar
RobertsAccount RobertsAccount is offline
X-Fi2 App Master
 
Join Date: Jan 2010
Location: UK
Posts: 310
Default

This is fantastic But we'll have to wait and see whether this compares to Creatives effort...
Reply With Quote

  #7  
Old 02-22-2010, 01:32 PM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,079
Default

Quote:
Originally Posted by Habhome View Post
Also I'm not sure if it really does tell you when it is impossible to win, I've been staring at this thing for quite a while and can't find a possible move. But don't take my word for it, as I said, I'm not the best at this game.
Quote:
Originally Posted by Tmd View Post
same as habhome i think i got to the point of no more possible moves but didn't get the notification in the game, but im not the best either.

The game works really nice though, maybe some sounds could be added in? thanks for taking the time to program =))
My bad, you do get the screen. It was just me interpreting the message as me making too many moves, which wasn't the case. So ignore that piece of my message =P
Perhaps should phrase it differently?
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^

Last edited by Habhome; 02-22-2010 at 01:46 PM.
Reply With Quote

  #8  
Old 02-22-2010, 02:16 PM
DanTheLegoMan DanTheLegoMan is offline
Junior Member
 
Join Date: Feb 2010
Posts: 38
Default

Thanks for all the comments.

I agree that the cards and the icon could have nicer graphics. I'll see if I can tweak them a bit - but I'm hopeless at graphics so don't expect too much!

Regarding the issue about not seeing an available move ... there could be a bug in my logic ... but in my testing I did always find a move eventually when there was one. Normally the turn would involve moving a part pile of cards from one stack to another in order to free a card that can move to one of the home piles. It doesn't always help - but just occasionally it does.

A stats feature would be a good addition - I need to look at how to save a file on the Zen to do that.
Reply With Quote

  #9  
Old 02-22-2010, 04:31 PM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,079
Default

Quote:
Originally Posted by DanTheLegoMan View Post
Thanks for all the comments.

I agree that the cards and the icon could have nicer graphics. I'll see if I can tweak them a bit - but I'm hopeless at graphics so don't expect too much!

Regarding the issue about not seeing an available move ... there could be a bug in my logic ... but in my testing I did always find a move eventually when there was one. Normally the turn would involve moving a part pile of cards from one stack to another in order to free a card that can move to one of the home piles. It doesn't always help - but just occasionally it does.

A stats feature would be a good addition - I need to look at how to save a file on the Zen to do that.
I must say this is one of the games I've played the most, and I finally one a game xD It's really entertaining when you're bored.

As for saving, check out Notee-fi, Simon, Pong, and a few others which have saving functionality for either stat or even text.

And I noticed you count the time it takes, could be implemented into the kitchen timer app RA have suggested.

As for graphics, I might be able to help. In my blackjack game I've made (for PC) I have some card images, but I don't know how they'll look resized, but I could give it a shot if you'd like?

Lastly, nice of you to make it "play in" all cards once you have them out on the table, so you won't have to tediously just drag every card into its correct place.

And one more thing, this is definitely my fav app out there atm. It's nice and "simple", but very entertaining. And it works awesome with only my right hand, no stylus needed really. It's very user friendly!
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^
Reply With Quote

  #10  
Old 02-23-2010, 04:21 AM
DanTheLegoMan DanTheLegoMan is offline
Junior Member
 
Join Date: Feb 2010
Posts: 38
Default

Quote:
Originally Posted by Habhome View Post
I must say this is one of the games I've played the most, and I finally one a game xD It's really entertaining when you're bored.
Thanks. I think that because you don't / can't win everytime it is very easy to play for a while until you finally get that win!

Quote:
Originally Posted by Habhome View Post
As for saving, check out Notee-fi, Simon, Pong, and a few others which have saving functionality for either stat or even text.
Good idea - I'll check them out.

Quote:
Originally Posted by Habhome View Post
And I noticed you count the time it takes, could be implemented into the kitchen timer app RA have suggested.
Sure - that would be easy to do. For any programmers reading this thread - I found that the os.difftime function does not work correctly for some reason (it does work in the simulator). For now I'm just doing ...

startTime = os.time()
--some time later
endTime = os.time()
timeTaken = endTime - startTime

It's not guaranteed to work according to the Lua specification as the values returned by os.time() may not be a integer, but it works on the Zen.

Quote:
Originally Posted by Habhome View Post
As for graphics, I might be able to help. In my blackjack game I've made (for PC) I have some card images, but I don't know how they'll look resized, but I could give it a shot if you'd like?.
I think the size of the cards (32 x 50 pixels) makes improving the graphics a challenge. e.g. I don't think there is room to put 10 little hearts on the 10 of hearts along with the current 10 and heart symbols in the top left and bottom right corners. I guess we could lose the bottom right corner number and suit symbol as it is not needed - but it will still be a big squeeze to fit everything in!

If you have time and the inclination to provide new graphics that would be awesome.

Quote:
Originally Posted by Habhome View Post
Lastly, nice of you to make it "play in" all cards once you have them out on the table, so you won't have to tediously just drag every card into its correct place.

And one more thing, this is definitely my fav app out there atm. It's nice and "simple", but very entertaining. And it works awesome with only my right hand, no stylus needed really. It's very user friendly!
Glad you like it. The "play in" thing was a welcome last minute addition because it definitely was a bit tedious at the end otherwise!
Reply With Quote

  #11  
Old 02-23-2010, 06:52 AM
DanTheLegoMan DanTheLegoMan is offline
Junior Member
 
Join Date: Feb 2010
Posts: 38
Default

I've tried to improve some of the graphics. I started with the Spades - and the results are in the attached zip file. The number cards now display the appropriate number of suit symbols, and the J,Q,K cards have some insect pictures on them (taken from iconshock.com).

What do you think?
Attached Files
File Type: zip Spades.zip (18.0 KB, 24 views)
Reply With Quote

  #12  
Old 02-23-2010, 06:59 AM
delirius delirius is offline
Member
 
Join Date: Feb 2010
Posts: 131
Default

wow, this app is absolutely awesome
Reply With Quote

  #13  
Old 02-23-2010, 07:23 AM
JJLoke JJLoke is offline
Junior Member
 
Join Date: Jan 2010
Posts: 87
Default

Hey Dan, I would like to ask u some code explanation

1)my player hangs when i set os.sleep(1) instead of os.sleep(10) and above. do u know y this happens ?

2)how do u prevent the images from forming a trail of images when it is drag across the screen?

thank you
Reply With Quote

  #14  
Old 02-23-2010, 07:52 AM
DanTheLegoMan DanTheLegoMan is offline
Junior Member
 
Join Date: Feb 2010
Posts: 38
Smile

Quote:
Originally Posted by JJLoke View Post
1)my player hangs when i set os.sleep(1) instead of os.sleep(10) and above. do u know y this happens ?
Hmmm, I'm not sure why that would be. I use os.sleep(1) in my app too. Does Solitaire crash on your Zen? If not, then perhaps it is related to the other calls you are making near the os.sleep call? Can you show me some of the code around the call?

Also, do you have the latest firmware installed (I think it is 1.11.01)? I saw in a different thread that re-installing the firmware can help with issues like this.

Quote:
Originally Posted by JJLoke View Post
2)how do u prevent the images from forming a trail of images when it is drag across the screen?
There is no API call to handle this. Unless your scene is very complex, you can simply re-draw the whole screen after processing the touch move messages (that is what I do in Solitaire). If re-drawing the whole screen is not an option, then you will have to draw just the part of the screen that was covered by the last position of the dragged image.

FYI, I found that input messages are generated faster than a screen update period. This means if you simply do ...

while (game loop)
--process button presses, touch etc ...
--draw screen including a call to screen.update()
end

If you are dragging an image using touch move messages the result is that you can slide your finger across the screen and then wait for a second before the image catches up with your finger.

Instead I put my input message processing in a loop of 6 iterations, e.g.

while (game loop) do
for i = 1, 6 do
--check for input and buttons and do something with them
end
--draw the screen
end

That means that the dragged image stays where your finger is dragging it.
Reply With Quote

  #15  
Old 02-23-2010, 08:09 AM
Habhome's Avatar
Habhome Habhome is offline
Moderator
 
Join Date: Jan 2010
Location: Sweden
Posts: 1,079
Default

Nice with the new spades. I think that design is usable. though some other image for JQK would be appreciated by me, these just look odd.
__________________
"If you are good enough at English to apologize, then there is no need to." - A good friend of mine
Discovered something about the X-Fi2 you think others may not know? Post it here so others can learn about it!
Have a question about X-Fi2 apps? Consult the FAQ before creating a thread about it.
Like my work? Tell your friends. Don't like it? Tell me so I can improve. ^.^
Reply With Quote

  #16  
Old 02-23-2010, 08:09 AM
JJLoke JJLoke is offline
Junior Member
 
Join Date: Jan 2010
Posts: 87
Default

thanks Dan, my player is always up to date

here is part of my affected code:

Quote:
function convsel()
z=z-xold
img_hg:draw(z,200,100,100)
img_thermo:draw(z+120,208,25,83.3)
screen.update()
end

while 1 do
if control.read()==1 then
if control.isTouch()==1 then
--if touch.click()==1 then --cause the program not to read values
-----------------------------------------------------------------------------------------------------------------------------
if touch.down() == 1 then
xold, yold = touch.pos()
z=xold xold, yold = touch.pos()
end

if touch.move() == 1 then x, y = touch.pos()
z=xold+(x-xold)
convsel() screen.update()
end

-----------------------------------------------------------------------------------------------------------------------------

--end --touch.click
end -- is.touch

if (control.isButton() == 1) and (button.home() == 1) and (button.click() == 1) then
screen.orientation(0)

break
end
--os.sleep(1) --removed temporily for troubleshooting, caused player to hang completely. >= os.sleep(10) required
end -- control read
end --close while
the memory buffer is quite high as convsel() is still drawing every position of new x, y coordinates. the fillrect to cover up the previous image is only masking the ghosting, but still very lag

as for the os.sleep(), i see that some applications does not even need that command. if i omit that, my player hangs too

if i include the masking and remove the os.sleep(), the creative sdk runs my program very smoothly, otherwise in the player will crash

Last edited by JJLoke; 02-23-2010 at 08:20 AM.
Reply With Quote

  #17  
Old 02-23-2010, 08:42 AM
reverof reverof is offline
Junior Member
 
Join Date: Feb 2010
Posts: 1
Default

Thank you very mach !
Good game

P.S. i'm not programmaker. But i can help do design (ikon, vizualisation).
Sorry, i'm speak in english bad.
Reply With Quote

  #18  
Old 02-23-2010, 08:56 AM
DanTheLegoMan DanTheLegoMan is offline
Junior Member
 
Join Date: Feb 2010
Posts: 38
Default

Quote:
Originally Posted by Habhome View Post
Nice with the new spades. I think that design is usable. though some other image for JQK would be appreciated by me, these just look odd.
So, would you be able to create some new images for the J,Q,K cards, if I work on updating the rest of the cards using the new style?
Reply With Quote

  #19  
Old 02-23-2010, 09:22 AM
JJLoke JJLoke is offline
Junior Member
 
Join Date: Jan 2010
Posts: 87
Default

Thanks Dan, i solved the problem. found my errors and rectified them. now image scrollig is smooth
Reply With Quote

  #20  
Old 02-23-2010, 09:25 AM
DanTheLegoMan DanTheLegoMan is offline
Junior Member
 
Join Date: Feb 2010
Posts: 38
Default

Quote:
Originally Posted by JJLoke View Post
thanks Dan, my player is always up to date

here is part of my affected code:

the memory buffer is quite high as convsel() is still drawing every position of new x, y coordinates. the fillrect to cover up the previous image is only masking the ghosting, but still very lag

as for the os.sleep(), i see that some applications does not even need that command. if i omit that, my player hangs too

if i include the masking and remove the os.sleep(), the creative sdk runs my program very smoothly, otherwise in the player will crash
I'm not exactly sure what is going on here, but there are few things that might be worth changing / trying.

You seem to be calling screen.update() twice for each touch.move message. I would remove the screen.update() call from convsel(). I would also move the other screen.update() call so it will be called every iteration of the while loop - i.e so it is not dependant on getting any input message.

Then add a for loop around the input checks to make sure you read all waiting message before you draw the screen.

Here is a complete application that allows you to touch on and move a playing card around the screen using those ideas ...

Code:
 
--replace 1s.png with your own image
dragImage=image.load("1s.png")
black = color.new(0,0,0)
cardX = 184;
cardY = 95;
dragX = 0;
dragY = 0;
dragXOffset = 0;
dragYOffset = 0;
dragging = 0
sheight = screen.height()
swidth= screen.width()
 
function drawScreen()
 screen.fillrect(0,0,swidth,sheight,black);
 if (dragging > 0) then
  dragImage:draw(dragX-dragXOffset,dragY-dragYOffset);
 else
  dragImage:draw(cardX,cardY)
 end
 screen.update()
end
 
function checkDrag(x,y)
 if (x >= cardX) and (x <= (cardX + 50)) and (y >= cardY) and (y <= (cardY + 32)) then
  dragging = 1;
  dragXOffset = x - cardX
  dragYOffset = y - cardY
 end
end
 
while (1) do
 for i = 1, 6 do
  if control.read()==1 then
   if control.isTouch()==1 then
    x,y = touch.pos()
    if (touch.move() == 1) then
     if (dragging == 0) then
      -- not dragging at the moment, check if we are starting a drag operation
      checkDrag(dragX,dragY);
     else
      -- currently dragging, so update dragX and dragY coordinates
      dragX = x;
      dragY = y;
     end
    elseif (touch.down() == 1) then
     -- record the position where the user starts a potential drag operation
     dragX = x;
     dragY = y;
    elseif (touch.up() == 1) then
     if (dragging > 0) then
      -- update cardX, cardY values
      cardX = dragX-dragXOffset;
      cardY = dragY-dragYOffset;
      dragging = 0;
     end
    end
   elseif control.isButton()==1 then
    if button.click() == 1 then
     quit = true
     break
    end
   end
  end
 end
 if (quit == true) then
  break;
 end
 drawScreen();
 screen.backlight(100)
 os.sleep(1)
end
 
--clean up
dragImage:close();
Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 01:24 AM.