Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

 
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

 
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
 
This is my favorite show. And this is my favorite tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic