Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Rotating Picture in Wheel of Fortune Game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
miller6




PostPosted: Mon Jan 18, 2010 11:36 am   Post subject: Rotating Picture in Wheel of Fortune Game

What is it you are trying to achieve?
I want to spin the wheel, and stop it at a specified degree (dependant on how long the spin button is held down for). The specified degree willl determine which section of the wheel it will land it on, thus giving the score for the player.

What is the problem you are having?
I cannot figure out how to get the wheel to spin just for the duration of time.

Describe what you have tried to solve this problem
I've tried playing around with the variables, adding more for loops, and extending the array paramaters.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing:


%%%%SPIN BUTTON
import GUI
buttonchoose ("multibutton")

var WinId : int
WinId := Window.Open ("position:centre;centre,graphics:700;455")

var SpinButton, ButtonPic, totTime : int
var picX := 70
var picY := 10
var SpinSpeed : real

var data_file : int
var phrase : string
var category : string
var guess : string (1)
var font1 : int
font1 := Font.New ("Arial:18:bold")
var picture : array 0 .. 35 of int
picture (0) := Pic.FileNew ("goodreelscaled.bmp")

const CTRx := Pic.Width (picture (0)) div 2
const CTRy := Pic.Height (picture (0)) div 2

fcn ButtonPressed : real
    var beginTime, endTime : int
    var x, y, buttonnumber, buttonupdown : int
    var button := 1

    loop
        buttonwait ("down", x, y, button, buttonupdown)

        if x > picX & x < picX + Pic.Width (ButtonPic)
                & y > picY & y < Pic.Width (ButtonPic) then
            beginTime := Time.Elapsed

            buttonwait ("up", x, y, button, buttonupdown)
            endTime := Time.Elapsed
            exit
        end if

    end loop

    SpinSpeed := (endTime - beginTime) / 1000
    result SpinSpeed

end ButtonPressed


proc SpinWheel

    if SpinSpeed > 0 & SpinSpeed < 1.5 then
        put "11111111"
    elsif SpinSpeed > 1.51 & SpinSpeed < 3.1 then
        put "22222"
    end if
   
    for angle : 1 .. 35
        picture (angle) := Pic.Rotate (picture (0), angle * 10, CTRx, CTRx)
    end for
    var x : int := CTRx
    var y : int := CTRx

    loop
        for angle : 0 .. 35
            Pic.Draw (picture (angle), x - CTRx, y - CTRx, picCopy)
            delay (100)
        end for
    end loop

end SpinWheel



%% BUTTON PICTURE
ButtonPic := Pic.FileNew ("button1.bmp")
Draw.Cls
Pic.Draw (ButtonPic, picX, picY, picCopy)


put "It took ", ButtonPressed, " seconds to run"
SpinWheel

%%%%%%SPINNING WHEEL
%%%HOW TO GET THE POINTS?
%%%HOW TO GET SPEED OF WHEEL?
for angle : 1 .. 35
    picture (angle) := Pic.Rotate (picture (0), angle * 10, CTRx, CTRx)
end for
var x : int := CTRx
var y : int := CTRx

loop
    for angle : 0 .. 35
        Pic.Draw (picture (angle), x - CTRx, y - CTRx, picCopy)
        delay (100)
    end for
end loop



Please specify what version of Turing you are using
4.1.1



button1.bmp
 Description:
Spin Button Picture
 Filesize:  184.63 KB
 Viewed:  552 Time(s)

button1.bmp



goodreelscaled.bmp
 Description:
Wheel Picture
 Filesize:  521.77 KB
 Viewed:  505 Time(s)

goodreelscaled.bmp


Sponsor
Sponsor
Sponsor
sponsor
miller6




PostPosted: Wed Jan 20, 2010 11:08 am   Post subject: RE:Rotating Picture in Wheel of Fortune Game

please help me
Zren




PostPosted: Wed Jan 20, 2010 2:46 pm   Post subject: RE:Rotating Picture in Wheel of Fortune Game

After looking at only this...
code:
loop
    for angle : 0 .. 35
        Pic.Draw (picture (angle), x - CTRx, y - CTRx, picCopy)
        delay (100)
    end for
end loop


We don't want it to always have to repeat a complete loop cycle, otherwise it will always land on the picture(35). Instead we want to ditch the for loop and manually increment and reset angle to 0 when it goes over 35. And on each loop cycle we need to check if the spin button is still pressed (Use Mouse.Where inside the loop instead of buttonwait). When it goes from clicked->not clicked, you could start a count of how many more spin cycles you go through (Randomness is best). Heck you could even slightly increse the delay between updates to make it appear it's slowing down.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: