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

Username:   Password: 
 RegisterRegister   
 Help needed....
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Mike Pastah




PostPosted: Fri Nov 08, 2002 10:36 pm   Post subject: Help needed....

Okay, I'm starting to experiment with making a game... I'll show you what I have so far:
code:
import GUI
GUI.SetBackgroundColor (black)
colorback (black)
Text.Color (white)
var q,w,e:string
var a, b, c, canvas : int
var chars : array char of boolean
a := 120
b := 120
c := 4

loop
drawfilloval (a, b, 10, 10, c)
    Input.KeyDown (chars)
    locate (1, 1)
    %Change colour
    if chars ('c') then
        put " "
        c += 1
    end if
    if c = 255 then
        put " "
        c := 0
    end if
    %Movement
    if chars (KEY_RIGHT_ARROW) then
        put "  "
        a += 1
        cls
    else
        put "   "
    end if

    if chars (KEY_LEFT_ARROW) then
        put "  "
        a += -1
        cls
    else
        put "  "
    end if

    if chars (KEY_UP_ARROW) then
        put "  "
        b += 1
        cls
    else
        put "  "
    end if

    if chars (KEY_DOWN_ARROW) then
        put " "
        b += -1
        cls
    else
        put "  "
    end if

    % Borders
    if a = maxx then
        put
            "  "
        a := 1
    end if

    if b = maxy then
        put
            " "
        b := 1
    end if

    if a = 0 then
        put
            " "
        a := maxx - 1
    end if

    if b = 0 then
        put " "
        b := maxy - 1

    end if
    delay (10)
end loop


There. Now I have some questions...
Question the first: How can I make the movement of the circle smoother, so it doesn't flash as it moves? If possible...
Question the second: How can I split the screen in two, so that I have a white frame or something on the bottom that has buttons etc. on it, without having to re-draw it every time I move the circle?
Question the third: Can I make the background a picture instead of just a colour, also so that the picture doesn't have to be re-drawn every time I move the circle...

I guess that's all for now, hope it all makes sense... Thanks for any help! Very Happy
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Sat Nov 09, 2002 10:00 pm   Post subject: hi

Hello and thanks for posting if you coude tell mw what version of turing you made this in it whode be help full buces there are difrent methods of doing what you whont that depened on your version of turing.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Mike Pastah




PostPosted: Sun Nov 10, 2002 2:43 am   Post subject: (No subject)

well, it's Turing Version 4.0.3 if that helps...
Tony




PostPosted: Sun Nov 10, 2002 3:54 am   Post subject: (No subject)

re Q1: It is known that turing has a very slow execution speed. So the trick is to minimize the time it takes to go from the cls command to the redraw. I sujest putting a cls right in front of draw command instead of putting it in each if statment.

re Q2: You can open another window and keep all your controls there. Though you'd have to constantly keep track of which window is active and switch between them to draw in appropriate one.

re Q3: yes, you can load a picture as your background.

I think it was something like:
code:
var picID: int := Pic.FileNew ("filename.jpg")
Pic.Draw(x,y,picID,picCopy)


It that doesn't work, look up in help file.

And no, you can not NOT erase the background while moving stuff on top... Not unless you have half-transparent screen with another monitor behind it Wink

But seriosly, drawing a background on top, will eliminate the need for cls command (so its less flashing). Through some huge files might cause a problem... I've also heard something about image buffering or w/e... I think there's some new feature that allows you to first draw the screen to memory, then it will all appear on the screen simutaniosly, eliminating and flashing... Though since I don't use turing anymore, I wouldn't know
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Mike Pastah




PostPosted: Sun Nov 10, 2002 7:20 am   Post subject: (No subject)

okay, i got rid of flashing using some weird offscreen type thing.. but now when i run the program, theres a black box on the top i cant get rid of...

just create and name a picture arg.bmp if you dont want to take that part out... heres my code...
code:
import GUI
GUI.SetBackgroundColor (black)
colorback (black)
Text.Color (white)
var a, b, c, canvas : int
var chars : array char of boolean
a := 120
b := 120
c := 4

var backgroundPictureX : int := 0
var backgroundPictureY : int := 0
var space : int
space := Pic.FileNew ("arg.bmp")



setscreen ("offscreenonly")
loop

    cls

    Pic.Draw (space, -backgroundPictureX, backgroundPictureY, picCopy)

    drawfilloval (a, b, 10, 10, c)
    Input.KeyDown (chars)
    locate (1, 1)
    %Change colour
    if chars ('c') then
        put " "
        c += 1
    end if
    if c = 255 then
        put " "
        c := 0
    end if
    %Movement
    if chars (KEY_RIGHT_ARROW) then
        put "  "
        a += 1

    else
        put "   "
    end if

    if chars (KEY_LEFT_ARROW) then
        put "  "
        a += -1

    else
        put "  "
    end if

    if chars (KEY_UP_ARROW) then
        put "  "
        b += 1

    else
        put "  "
    end if

    if chars (KEY_DOWN_ARROW) then
        put " "
        b += -1

    else
        put "  "
    end if

    % Borders
    if a = maxx then
        put
            "  "
        a := 1
    end if

    if b = maxy then
        put
            " "
        b := 1
    end if

    if a = 0 then
        put
            " "
        a := maxx - 1
    end if

    if b = 0 then
        put " "
        b := maxy - 1

    end if
    delay (8)
    View.Update
end loop
setscreen ("nooffscreenonly")


idunno... Shocked
Tony




PostPosted: Sun Nov 10, 2002 7:32 am   Post subject: (No subject)

in If statments for movement, you got else put " "

thats probably your problem... since you set colorback as black, " " would draw a black box.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Mike Pastah




PostPosted: Mon Nov 11, 2002 1:48 am   Post subject: (No subject)

You were right! But i figured it out at school... ripped the whole thing apart... no further questions, please stand by... Very Happy
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  [ 7 Posts ]
Jump to:   


Style:  
Search: