
-----------------------------------
ImDaMan
Mon Oct 09, 2006 6:30 pm

Need Help
-----------------------------------
Hey everyone, i started programming about a month ago so i'm pretty noobie. I'm currently programming a game right now and I want get Turing to play music while I play the game, how do I do that.
oh yeah, one more thing, my plane keeps flickering even when I use View.Update, anyone got any ideas? :? 
As I have said before, i'm pretty noobie, so here are my codes, I bet there are simple ways to do some of these codes. :oops: 


Music.PlayFile ("c:/Cherub rock.wav")
View.Set ("graphics,offscreenonly,nocurser")
var a, b, c, d, e, f : int
var x, y : int
x := 100
y := 100
var chars : array char of boolean
var ship : int := Pic.FileNew ("c:/game resources/ship.bmp")
var fire : int := Pic.FileNew ("c:/game resources/fire.bmp")
var planet1 : int := Pic.FileNew ("c:/game resources/planet1.bmp")
var planet2 : int := Pic.FileNew ("c:/game resources/planet2.bmp")
colourback (7)
cls
randomize
a := Rand.Int (300, 400)
b := Rand.Int (200, 400)
c := Rand.Int (200, 300)
d := Rand.Int (0, 200)
loop
    View.Update
    Pic.Draw (planet1, a, b, 0)
    View.Update
    Pic.Draw (planet2, c, d, 0)
    Input.KeyDown (chars)
    if chars (KEY_UP_ARROW) then
        y := y + 20
    end if
    if chars (KEY_DOWN_ARROW) then
        y := y - 20
    end if
    if chars (KEY_LEFT_ARROW) then
        x := x - 20
    end if
    if chars (KEY_RIGHT_ARROW) then
        x := x + 20
    end if
    View.Update
    Pic.Draw (ship, x, y, 0)
    delay (70)
    cls
    Input.KeyDown (chars)
    if chars (KEY_ENTER) then
        var m, n : int
        m := x
        n := y
        View.Update
        Pic.Draw (ship, x, y, 0)
        for decreasing counter : 8 .. 1
            Pic.Draw (ship, x, y, 0)
            View.Update
            Pic.Draw (fire, m + 100, n + 34, 0)
            delay (20)
            cls
            View.Update
            Pic.Draw (fire, m + 100, n - 5, 0)
            delay (20)
            cls
            View.Update
            Pic.Draw (ship, x, y, 0)
            m := m + 100
            View.Update
            Pic.Draw (planet1, a, b, 0)
            View.Update
            Pic.Draw (planet2, c, d, 0)
        end for
        View.Update
        Pic.Draw (planet1, a, b, 0)
        View.Update
        Pic.Draw (planet2, c, d, 0)
        Music.PlayFile ("c:/missile5.wav")
        View.Update
        Pic.Draw (ship, x, y, 0)
        if m = a or c = m and n = b or n = d then
            locate (10, 50)
            put "you got em..."
            Music.PlayFile ("c:/explosion2.wav")
        end if
    end if
end loop



-----------------------------------
Clayton
Mon Oct 09, 2006 6:37 pm


-----------------------------------
ok, first of all, get rid of the randomize in there, you dont need it, it was used way back when in like 3.x versions of Turing (even before that i believe actually) and is no longer used. next, you only need one View.Update in there, the reason it is flashing is because you draw your picture, then clear the screen, then View.Update, so you see a clear screen for a second then you get the picture :( check out my View.Set and View.Update tutorial in the Turing Walkthrough :D

to get the music to play while everything else is happening use the Music.PlayFileReturn (filename:string) procedure (well process really...) and you should be fine :D

-----------------------------------
Silent Avenger
Mon Oct 09, 2006 6:39 pm


-----------------------------------
Well first off you shouldn't post threads with subjects of "need help". Next time put in something you need help with in the subject so in your case you might put "need help with playing music and flickering". I've also found a tutorial on the haltsoft website for you, the link is below.
http://www.holtsoft.com/turing/tech/music.html

-----------------------------------
ImDaMan
Mon Oct 09, 2006 6:41 pm

ty
-----------------------------------
Thanks :) 

btw: I know this probably sounds stupid but how do you actual use that command? (filename:string)?? :oops:

-----------------------------------
ImDaMan
Mon Oct 09, 2006 6:52 pm

nvm that last message
-----------------------------------
nvm, I found out how.... :oops:

-----------------------------------
Silent Avenger
Mon Oct 09, 2006 7:18 pm


-----------------------------------
Well it's a good thing that you figured out how to do it yourself because that's how you really learn, by figuring things out by yourself and not having people telling you what to do.

-----------------------------------
Cervantes
Mon Oct 09, 2006 7:22 pm


-----------------------------------
"Music.PlayFileReturn (filename:string)" means that the Music.PlayFileReturn procedure takes one parameter and that parameter is a string. It is referred to as "filename" in the definition of the procedure.

You'll start to use this syntax when you start [url=http://www.compsci.ca/v2/viewtopic.php?t=407]defining your own subroutines.
