1

I'm trying to program a Roulette game for my capstone class. I've been trying to find a way to code the wheel but I'm new to java and have no idea how to start. I found paintComponent(Graphics g) method helps rotating my wheel image but not the way the wheel should spin. Is there any way I can do it, any articles that would give me an ideas how to start. Any help will be much appreciated.

Jens Björnhager
  • 5,632
  • 3
  • 27
  • 47
user1172575
  • 59
  • 1
  • 7
  • 5
    New to Java? Capstone project? I don't think that's a good idea (not saying this to be rude or anything, but capstones are tough, and you should be knowledgeable in the language/domain you're working in). Anyway, what have you tried? Have you looked into any tutorials? What code do you have, where is it not working properly? – Makoto May 11 '12 at 15:25
  • 1
    Implement a Swing `Timer` to call `repaint()`. That is about all I can suggest from the paucity of information in your question. Having said that, I agree with @Makoto. Start with simpler stuff or ask better, more specific questions. – Andrew Thompson May 11 '12 at 15:29
  • A little bit confusing I know but I only took an introduction to Java class and I'm learning the language by myself. My projects for the capstone class are harder than what my degree (AA)requires that's why I'm lost. I've tried rotating my wheel image using image.rotate(radian)but not working the way it should. any articles or start points will be helpful...Thanks – user1172575 May 11 '12 at 15:35
  • 2
    Take a look at the [RotatingIcon](http://tips4java.wordpress.com/2009/04/06/rotated-icon/) class and perhaps [this answer of mine](http://stackoverflow.com/questions/10055336/jtabbedpane-show-task-progress-in-a-tab/10055387#10055387) where I used that `RotatingIcon` class in combination with a timer to show a busy icon. Might come in handy for making a Roulette – Robin May 11 '12 at 15:37
  • Thank you very much. That's exactly what I needed. Thank you Makoto, Andrew Thampson,and Robin for your answers. I know my questions are not clear enough but I'm not an English native speaker and that effects my way of asking. thanks again – user1172575 May 11 '12 at 15:46
  • 2
    We haven't provided any answers, only comments which can not be accepted (nor take we any credits for the upvotes). And your English is good enough. I have seen a lot of questions where the English was harder to understand – Robin May 11 '12 at 15:50
  • @trashgod your answer is good enough to get accepted. At least it points to some code you have written, where my comment refers to a class I found on the internet – Robin May 11 '12 at 19:23

2 Answers2

2

This example shows how to rotate an arbitrary image. This Q&A may suggest how to rotate the text, if you create your own image at run-time.

Addendum: In helpful comments, @Robin recalls this example, as well as @camickr's pivotal article Rotated Icon. As the goal is to model a game of roulette with a rotating wheel view, the MVC pattern may prove useful.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
0

Here's two great rotation libraries that have an out-of-the-box fling-to-spin behaviour https://bitbucket.org/warwick/hg_dial_v2 https://bitbucket.org/warwick/hgdialrepo

And here's a gesture library that implements the above code. https://bitbucket.org/warwick/hacergestov3

user2288580
  • 2,210
  • 23
  • 16