Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualIndignant

Posted 10 December 2012 - 04:02 AM

Hello!
First of all, because here we are talking about a spinning wheel, we should probably describe initial speed as degree per frame. So, say if the initial speed is x degree/frame, the the speed in n th frame should be S(n) = x - a(n^2). To make the wheel spin, you just need to call the correct function to rotate the wheel object S degree every frame. Here is some pseudo code(display() is the disply loop that should be called in every game loop ):

int frame = 0;
double Si = 0;
double S = 0;

display() {
//draw background
if (S > 0) {
S = Si - a*frame*frame;
frame++;
if (S > 0) {
rotate S degrees;
}
} else { //end of game, call what you should call }
swapBuffer();
}

Just my two sents, maybe -a(x^2) is not a good option, because it causes the wheel to slow down faster at the end. In a wheel game like this, usually the last few seconds are the most exciting ones, so maybe you should simply use S(n) = x- a*n instead.

int frame = 0;
double S = 0;

display() {
//draw background
if (S > 0) {
S -= a;
if (S > 0) {
rotate S degrees;
}
} else { //end of game, call what you should call }
swapBuffer();
}

to start the spin, simply assign a value(the initial speed) to S.

Hope your lucky wheel get you good luck! Posted Image

#1Indignant

Posted 10 December 2012 - 04:02 AM

Hello!
First of all, because here we are talking about a spinning wheel, we should probably describe initial speed as degree per frame. So, say if the initial speed is x degree/frame, the the speed in n th frame should be S(n) = x - a(n^2). To make the wheel spin, you just need to call the correct function to rotate the wheel object S degree every frame. Here is some pseudo code(display() is the disply loop that should be called in every game loop ):

int frame = 0;
double Si = 0;
double S = 0;

display() {
//draw background
if (S > 0) {
S = Si - a*frame*frame;
frame++;
if (S > 0) {
rotate S degrees;
}
} else { //end of game, call what you should call }
swapBuffer();
}

Just my two sents, maybe -a(x^2) is not a good option, because it causes the wheel to slow down faster at the end. In a wheel game like this, usually the last few seconds are the most exciting ones, so maybe you should simply use S(n) = x- a*n instead.

int frame = 0;
double S = 0;

display() {
//draw background
if (S > 0) {
S -= a;
frame++;
if (S > 0) {
rotate S degrees;
}
} else { //end of game, call what you should call }
swapBuffer();
}

to start the spin, simply assign a value(the initial speed) to S.

Hope your lucky wheel get you good luck! :D

PARTNERS