Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Shuffle Game that i created is not working as i expect.

 
Nitesh Panchal
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I created a code which you may be very well aware of the game in which randomly numbers appear on all squares and then you have to rearrange all the nos using the arrow keys. Here is the code i created it so far. I don't know where the problem is but the keylisteners in general are not behaving as i expected them to be. Any help would be greatly appreciated! i tried all possible things i knew but still just unable to make where the problem lies! logically and syntactically it's all right but still its not working

 
amitabh mehra
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:

introduce a new int variable focussed:


set this in init:


in keyPressed, reassign focussed to space:


and later in each case statment, after all calculations on space, assign it back to focussed:



edited>> bold tag didnt work within code tag
 
Nitesh Panchal
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks amitabh mehra
apparently i found out that i declared 2 times space variable one as instance variable and second as local variable in init() and obviously in init() the space is not required. If you remove it the program works fine!
 
amitabh mehra
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops... totally missed out on that
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic