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

Username:   Password: 
 RegisterRegister   
 Turing Made Joystick
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
xHoly-Divinity




PostPosted: Sat Nov 04, 2006 4:11 pm   Post subject: Turing Made Joystick

Someone should use this and see if they could make a game with it, that would be pretty sweet Very Happy . Ok, so the code probably could have been a bit shorter, but I LIKE IT!!! Cool

code:

setscreen ("offscreenonly")
var x, y : int := 200
var q, r : int := 400
r := 200
var num : int := 1
drawfillbox (q, r, q + 100, r + 100, black)
drawfillbox (100, 100, 300, 300, grey)
proc draw
    drawfilloval (x, y, 30, 30, 12)
end draw
proc erase
    drawfilloval (x, y, 30, 30, white)
end erase
loop
    drawline (200, 200, x, y, white)
    drawfillbox (100, 100, 300, 300, grey)
    var a, b, press : int
    mousewhere (a, b, press)
    draw
    if whatdotcolor (a, b) = 12 and press = 1 then
        loop
            mousewhere (a, b, press)
            x := a
            y := b
            if x + 30 > 300 then
                x := 300 - 30
            end if
            if x - 30 < 100 then
                x := 100 + 30
            end if
            if y + 30 > 300 then
                y := 300 - 30
            end if
            if y - 30 < 100 then
                y := 100 + 30
            end if
            cls
            if press = 1 then
                q += round ((x - 200) / 1.5)
                r += round ((y - 200) / 1.5)
                if q < 0 then
                    q := 0
                end if
                if q + 100 > maxx then
                    q := maxx - 100
                end if
                if r < 0 then
                    r := 0
                end if
                if r + 100 > maxy then
                    r := maxy - 100
                end if
            end if
            delay (100)
            drawfillbox (q, r, q + 100, r + 100, black)
            drawfillbox (100, 100, 300, 300, grey)
            drawline (200, 200, x, y, black)
            draw
            View.Update
            if press not= 1 then
                erase
                drawfillbox (100, 100, 300, 300, grey)
                drawline (200, 200, x, y, white)
                x := 200
                y := 200
                exit
            end if
        end loop
    end if
    drawline (200, 200, x, y, white)
    draw
    View.Update
end loop
Sponsor
Sponsor
Sponsor
sponsor
ericfourfour




PostPosted: Sat Nov 04, 2006 4:14 pm   Post subject: (No subject)

Turing already has a joystick library and it is really easy to use (If i remember correctly). It just isn't documented. It will work with controllers, and possibly steering wheels.
xHoly-Divinity




PostPosted: Sat Nov 04, 2006 4:24 pm   Post subject: (No subject)

This isn't a real joystick/wheel (duh!), run the program, it's an interfacable joystick on the output screen Smile
NikG




PostPosted: Sun Nov 05, 2006 1:03 am   Post subject: (No subject)

That's not bad!
Why don't YOU trying making a game out of it.
xHoly-Divinity




PostPosted: Sun Nov 05, 2006 12:19 pm   Post subject: (No subject)

NikG wrote:
Why don't YOU trying making a game out of it.


Im experimenting on a few other ideas. There are also a few time constraints. This way, ne1 with a bit of extra time could fool around with the code and see what they can do Smile
Dannyd534




PostPosted: Mon Nov 13, 2006 7:11 pm   Post subject: (No subject)

alright...this is cool but do u think there is any way to hook this program through a printer port to like an RC car and make it move when u move the joystick on this program???
[Gandalf]




PostPosted: Tue Nov 14, 2006 12:08 am   Post subject: (No subject)

I'm sure it is, through the parallel port, but it's up to you to figure out how.
Dannyd534




PostPosted: Tue Nov 14, 2006 10:31 pm   Post subject: (No subject)

ugh parallel port Razz
Sponsor
Sponsor
Sponsor
sponsor
Prince Pwn




PostPosted: Fri Nov 17, 2006 11:39 pm   Post subject: (No subject)

That is a sweet joystick. My friend had to make one in grade 12 comp. engineering (a real joystick) and run it through Turing's parallelport and parallelget procedures. But that would be sweet if you did that and made your joystick move on the screen in full 360 as your joystick would Wink
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: