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

Username:   Password: 
 RegisterRegister   
 Background Music, Picture, and Logo
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jurica




PostPosted: Mon Nov 24, 2008 6:21 pm   Post subject: Background Music, Picture, and Logo

Hello, I have a problem with putting my Background Picture, my music, and my logo just going across the screen. I got basically all the code just don't know how to put the stuff. Can you guys please tell me how to?

Turing:

var logoPicID, bgPicID : int    % The picture Ids of the logo and the bkgrnd
var logoWidth, logoHeight : int % The width and height of the logo picture
var x, y : int := 0             % The location of the logo
var dx, dy : int := 3           % The direction of movement of the logo
var finished : boolean := false % Set to true when program finished

% Process to continuously play background music
process PlayBackgroundMusic (filename : string)
    loop
        exit when finished
        Music.PlayFile (filename)
    end loop
end PlayBackgroundMusic

% Process to play a sound file once
process PlaySoundEffect (filename : string)
    Music.PlayFile (filename)
end PlaySoundEffect

% Load the logo from file and get its height and width
logoPicID := Pic.FileNew ("logo.bmp") % I want it to be what i want but it won't show up
logoWidth := Pic.Width (logoPicID)
logoHeight := Pic.Height (logoPicID)

% Load the forest picture from the file and draw it to the window
Pic.ScreenLoad ("ThisIsWhereAPicutreWillBeButWhenIPutDoesn'tWork.bmp", 0, 0, picCopy)

% Start the background music
fork PlayBackgroundMusic ("background.mid")

loop
    exit when hasch
    bgPicID := Pic.New (x, y, x + logoWidth, y + logoHeight)
    Pic.Draw (logoPicID, x, y, picMerge)
    delay (50)
    Pic.Draw (bgPicID, x, y, picCopy)
    Pic.Free (bgPicID)
    if x + dx < 0 or x + dx + logoWidth > maxx then
        fork PlaySoundEffect ("boing.wav")
        dx := - dx
    end if
    if y + dy < 0 or y + dy + logoHeight > maxy then
        fork PlaySoundEffect ("boing.wav")
        dy := - dy
    end if
    x := x + dx
    y := y + dy
end loop

finished := true
Music.PlayFileStop
Sponsor
Sponsor
Sponsor
sponsor
Tyr_God_Of_War




PostPosted: Mon Nov 24, 2008 8:09 pm   Post subject: RE:Background Music, Picture, and Logo

It works for me once I added some of my own pics and music. The SFX interrupts the background music though. Also you could add View.Set at the beginning and View.Update before the delay.
copthesaint




PostPosted: Tue Nov 25, 2008 8:04 am   Post subject: Re: Background Music, Picture, and Logo

Well first I advise you that you create a folder for all your pictures create a folder for your music and but those folders in a folder with your game. (organiztion)

Next

You Should just name your processes a name even process darthvader, and where you have put

code:
process PlayBackgroundMusic (filename : string)
    loop
        exit when finished
        Music.PlayFile (filename)
    end loop
end PlayBackgroundMusic


If you want this music to loop just put

code:
process PlayBackgroundMusic
        Music.PlayFileLoop (Music/Mybackroundmusic.mp3)
end PlayBackgroundMusic


and when you want the music to end put

code:
Music.PlayFileStop


also as I mentioned I had done above and just named the files.
anywas try it out after. (I did not use turing so Sorry if Music.PlayFileStop is wrong)

Lastly for your pic simply use

var backpic := Pic.FileNew ("Pictures/backpic.jpg")
Pic.Draw (backpic, 0, 0, picMerge)or picCopy or picUnderMerge
%then at the end of loop
Pic.Free (backpic)
Jurica




PostPosted: Tue Nov 25, 2008 5:47 pm   Post subject: Re: Background Music, Picture, and Logo

Okay, I'm almost finished it. I just need Background Music and it's pretty hard to do, I've tried everything and it still don't work. Here's the code and see if I've done anything wrong with it.

Turing:

% Changes Screen Resolution
View.Set ("graphics:380,257,nobuttonbar")

% Variables
var z, c, button : int
var logoPicID, bgPicID : int
var logoWidth, logoHeight : int
var x, y : int := 0
var dx, dy : int := 3
var finished : boolean := false

% Process to continuously play background music
process PlayBackgroundMusic (filename : string)
    loop
        exit when finished
        Music.PlayFile (filename)
    end loop
end PlayBackgroundMusic

% Process to play a sound file once
process PlaySoundEffect (filename : string)
    Music.PlayFile (filename)
end PlaySoundEffect

% Loads Logo
logoPicID := Pic.FileNew ("logo.bmp")
logoWidth := Pic.Width (logoPicID)
logoHeight := Pic.Height (logoPicID)

% Loads Background
Pic.ScreenLoad ("background.bmp", 0, 0, picCopy)

% Moves Logo
loop
   bgPicID := Pic.New (x, y, x + logoWidth, y + logoHeight)
   Pic.Draw (logoPicID, x, y, picMerge)
   delay (50)
   Pic.Draw (bgPicID, x, y, picCopy)
   Pic.Free (bgPicID)
   if x + dx < 0 or x + dx + logoWidth > maxx then
      fork PlaySoundEffect ("boing.wav")
      dx := -dx
   end if
   if y + dy < 0 or y + dy + logoHeight > maxy then
      fork PlaySoundEffect ("boing.wav")
      dy := -dy
   end if
   x := x + dx
   y := y + dy
   Mouse.Where (z, c, button)
   if button = 1 then
      locatexy (maxx div 1.5, maxy div 1)
      put "X=", z," : Y=",c
      delay (0)
   end if 
end loop
andrew.




PostPosted: Tue Nov 25, 2008 8:13 pm   Post subject: RE:Background Music, Picture, and Logo

What happens if you put fork PlayBackgroundMusic (filename) before the loop? That should work.

P.S. Since your sound effect is WAV, try to keep the background music something else like MIDI or MP3 because if there are 2 of the same sound file types being played at once, one will have to stop.
Jurica




PostPosted: Wed Nov 26, 2008 7:12 am   Post subject: Re: RE:Background Music, Picture, and Logo

andrew. @ Tue Nov 25, 2008 8:13 pm wrote:
What happens if you put fork PlayBackgroundMusic (filename) before the loop? That should work.

P.S. Since your sound effect is WAV, try to keep the background music something else like MIDI or MP3 because if there are 2 of the same sound file types being played at once, one will have to stop.

If I put a fork PlayBackgroundMusic (filename) before the loop, I get an error. And I used an MP3 file and it didn't work, so I decided to try a WAV file, still worked but when the logo touches the wall then it starts, I want it to start right when the run the program. And I don't know hot to make an MIDI file, that's my only hope to work it and I don't know how to make one. So if anyone can show me how to make one that'd be greatly appreciated.
ecookman




PostPosted: Wed Nov 26, 2008 8:16 am   Post subject: RE:Background Music, Picture, and Logo

a hella lot easier if you use turing V4.1


outside of the loop just put

Music.PlayFileLoop ("[name].[type]")

and where you want it to stop put


Music.PlayFileStop


this stops the file from playing
S_Grimm




PostPosted: Wed Nov 26, 2008 11:32 am   Post subject: RE:Background Music, Picture, and Logo

First, 4.1.x has an erorr in the header file that does not allow compiling into a separte .exe program. so, if Jurica wants to distribute this program, every person must have turing 4.1.x installed on their computer in order to make it run. Along with that, Jurica would be distributing the source code, which people could copy and pass off as their own. (Plagarism)

Second, as for converting an mp3 file into MIDI, it is not recomended. a .mp3 file is recored music. A MIDI file is basically sheet music. It is fine to convert, say just a piano playing into midi, but converting a full band (guitar, bass, drums, singer, etc.) will lose a lot of quality.

However, it can be done. I found this via google. take a look at the links on this page.

http://answers.yahoo.com/question/index?qid=20081021101405AAhMLFt

or this page (Linked from previous page)

http://www.mymusictools.com/articles/how-do-i-convert-mp3-to-midi.htm

edit: Spelling mistakes. Sorry Smile
Sponsor
Sponsor
Sponsor
sponsor
MihaiG




PostPosted: Wed Nov 26, 2008 3:11 pm   Post subject: Re: Background Music, Picture, and Logo

im fairly sure in regards to using turing version 4.0.5 has all (i think...) the features that 4.1.x has

thats true its fairly hard to convert mp3 to midi, because midi stores intrument data, in the file, it is very poor qaulity and not much tonal variety, what you could do, is you can use the Sys.Exec() command to essentially execute an mp3 file, it will open up with winmedia player or something, and then you could have a batch script that kills the winmedia process, my friend did this for final project since playing the file with turing was giving him performance issues
S_Grimm




PostPosted: Wed Nov 26, 2008 3:14 pm   Post subject: RE:Background Music, Picture, and Logo

Or you can compose a song using turings built in music commands............
Jurica




PostPosted: Wed Nov 26, 2008 5:46 pm   Post subject: RE:Background Music, Picture, and Logo

Thanks guys for your help, I'm finally finished. Here is the solution to it:
Turing:

% Changes Screen Resolution
View.Set ("graphics:380,257,nobuttonbar")

% Variables
var z, c, button : int
var logoPicID, bgPicID : int
var logoWidth, logoHeight : int
var x, y : int := 0
var dx, dy : int := 3
var finished : boolean := false

% Process to continuously play background music
process PlayBackgroundMusic (filename : string)
    loop
        exit when finished
        Music.PlayFile (filename)
    end loop
end PlayBackgroundMusic

% Process to play a sound file once
process PlaySoundEffect (filename : string)
    Music.PlayFile (filename)
end PlaySoundEffect

% Loads Logo
logoPicID := Pic.FileNew ("logo.bmp")
logoWidth := Pic.Width (logoPicID)
logoHeight := Pic.Height (logoPicID)

% Loads Background
Pic.ScreenLoad ("background.bmp", 0, 0, picCopy)

% Music
Music.PlayFileLoop ("backgroundsongfor.mp3")

% Moves Logo
loop
   bgPicID := Pic.New (x, y, x + logoWidth, y + logoHeight)
   Pic.Draw (logoPicID, x, y, picMerge)
   delay (50)
   Pic.Draw (bgPicID, x, y, picCopy)
   Pic.Free (bgPicID)
   if x + dx < 0 or x + dx + logoWidth > maxx then
      fork PlaySoundEffect ("beep.wav")
      dx := -dx
   end if
   if y + dy < 0 or y + dy + logoHeight > maxy then
      fork PlaySoundEffect ("beep.wav")
      dy := -dy
   end if
   x := x + dx
   y := y + dy
   Mouse.Where (z, c, button)
   if button = 1 then
      locatexy (maxx div 1.5, maxy div 1)
      put "X=", z," : Y=",c
   end if
end loop
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  [ 11 Posts ]
Jump to:   


Style:  
Search: