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

Username:   Password: 
 RegisterRegister   
 Sprites ontop of Background
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Lawlly




PostPosted: Thu Dec 20, 2007 7:57 pm   Post subject: Sprites ontop of Background

Alright so I've created sprites and drew a background using a picture. My problem is that my sprites are basically a rectangular picture with a guy and a white background. I never thought that when I put it on my background the white box would show over the background pic. How can I fix this? I've thought of making my picture transparent, which I have no clue how to do, Or cutting out the guy from the rectangular white picture. Sadly, I keep failing at this entire project and am losing faith. Could anyone help me out on this?

Thx,
Lawlly
Sponsor
Sponsor
Sponsor
sponsor
HeavenAgain




PostPosted: Thu Dec 20, 2007 7:59 pm   Post subject: RE:Sprites ontop of Background

you probably used picCopy or somesort
replace it with picMerge and see
Lawlly




PostPosted: Thu Dec 20, 2007 8:32 pm   Post subject: Re: RE:Sprites ontop of Background

HeavenAgain @ Thu Dec 20, 2007 7:59 pm wrote:
you probably used picCopy or somesort
replace it with picMerge and see


How does picMerge work? I read something about transparent color in the Turing Directory though I didn't know what it was talking about.
HeavenAgain




PostPosted: Thu Dec 20, 2007 8:43 pm   Post subject: RE:Sprites ontop of Background

i believe picMerge just ignores the background of the picture, im not sure how it works inside that command, think of it as transparent i guess.
but hey, it works right? Rolling Eyes
Lawlly




PostPosted: Thu Dec 20, 2007 9:10 pm   Post subject: Re: Sprites ontop of Background

No lol.
HeavenAgain




PostPosted: Thu Dec 20, 2007 9:22 pm   Post subject: RE:Sprites ontop of Background

give a background color for your sprite and try using picMerge
Lawlly




PostPosted: Thu Dec 20, 2007 10:02 pm   Post subject: Re: Sprites ontop of Background

How to give background colour? o_O
HeavenAgain




PostPosted: Thu Dec 20, 2007 10:16 pm   Post subject: RE:Sprites ontop of Background

you are using sprite right? open your photoshop or paint or something? make the background color red black green blue white.. anything o_o and use picMerge..... you shouldn't have too much problem with it
Sponsor
Sponsor
Sponsor
sponsor
Lawlly




PostPosted: Thu Dec 20, 2007 11:05 pm   Post subject: Re: Sprites ontop of Background

Alright well this thing is due tomorrow and this project i've made is probably more advanced than he would expect so I don't care if its a little shitty.

Now, i've decided to skip that part for now and move on to forks. That's something that's very important for my program since no 2 keys can be hit at the same time. Can you show me how to use forks in my prog?...

Turing:
%**************************************************************************************************
%*************************************** Variable Declaration *************************************
%**************************************************************************************************



%Ryu Player 1 Punch
var pic1 : int := Pic.FileNew ("RyuPunch1.jpg")
var pic2 : int := Pic.FileNew ("RyuPunch2.jpg")
var pic3 : int := Pic.FileNew ("RyuPunch3.jpg")

%Ryu Player 1 Walk
var PicWalk1 : int := Pic.FileNew ("RyuWalk1.jpg")
var PicWalk2 : int := Pic.FileNew ("RyuWalk2.jpg")
var PicWalk3 : int := Pic.FileNew ("RyuWalk3.jpg")
var PicWalkL1 : int := Pic.FileNew ("RyuWalkL1.jpg")
var PicWalkL2 : int := Pic.FileNew ("RyuWalkL2.jpg")

%Yang Player 2 Walk
var yangwalk1 : int := Pic.FileNew ("yangwalk1.jpg")
var yangwalk2 : int := Pic.FileNew ("yangwalk2.jpg")
var yangwalk3 : int := Pic.FileNew ("yangwalk3.jpg")
var yangwalk4 : int := Pic.FileNew ("yangwalk4.jpg")
var yangwalk5 : int := Pic.FileNew ("yangwalk5.jpg")

%Yang Player 2 Punch
var yangpunch1 : int := Pic.FileNew ("yangpunch1.jpg")
var yangpunch2 : int := Pic.FileNew ("yangpunch2.jpg")
var yangpunch3 : int := Pic.FileNew ("yangpunch3.jpg")
var yangpunch4 : int := Pic.FileNew ("yangpunch4.jpg")

%Ryu Punch Create Sprites
var sprite1 : int := Sprite.New (pic1)
var sprite2 : int := Sprite.New (pic2)
var sprite3 : int := Sprite.New (pic3)

%Ryu Walk Create Sprites
var SpriteWalk1 : int := Sprite.New (PicWalk1)
var SpriteWalk2 : int := Sprite.New (PicWalk2)
var SpriteWalk3 : int := Sprite.New (PicWalk2)
var SpriteWalkL1 : int := Sprite.New (PicWalkL1)
var SpriteWalkL2 : int := Sprite.New (PicWalkL2)

%Yang Walk Create Sprites
var spritewalk1 : int := Sprite.New (yangwalk1)
var spritewalk2 : int := Sprite.New (yangwalk2)
var spritewalk3 : int := Sprite.New (yangwalk3)
var spritewalk4 : int := Sprite.New (yangwalk4)
var spritewalk5 : int := Sprite.New (yangwalk5)

%Yang Punch Create Sprites
var spritepunch1 : int := Sprite.New (yangpunch1)
var spritepunch2 : int := Sprite.New (yangpunch2)
var spritepunch3 : int := Sprite.New (yangpunch3)
var spritepunch4 : int := Sprite.New (yangpunch4)

% Declare other variables
var x, y : int := 50
var x2, y2 : int
var centered : boolean := false
var chars : array char of boolean

x2 := 400
y2 := 50

%**************************************************************************************************
%******************************************* Set Sprite Height ************************************
%**************************************************************************************************

%Ryu Player 1 Sprite Height
Sprite.SetHeight (sprite1, 1)
Sprite.SetHeight (sprite2, 1)
Sprite.SetHeight (sprite3, 1)

%Ryu Player 1 Walk Sprite Height
Sprite.SetHeight (SpriteWalk1, 1)
Sprite.SetHeight (SpriteWalk2, 1)
Sprite.SetHeight (SpriteWalk3, 1)

Sprite.SetHeight (SpriteWalkL1, 1)
Sprite.SetHeight (SpriteWalkL2, 1)

%Sprite Initial Position

Sprite.SetPosition (sprite1, x, y, centered)
Sprite.Show (sprite1)
Sprite.SetPosition (spritewalk1, x2, y2, centered)
Sprite.Show (spritewalk1)


%**************************************************************************************************
%******************************************* Procedure Creation ***********************************
%**************************************************************************************************

proc Player1Punch
    Sprite.Hide (sprite1)

    Sprite.Animate (sprite2, pic2, x, y, centered)
    Sprite.Show (sprite2)
    delay (120)

    Sprite.Animate (sprite3, pic3, x, y, centered)
    Sprite.Hide (sprite2)
    Sprite.Show (sprite3)
    delay (120)

    Sprite.Hide (sprite3)
    Sprite.Show (sprite2)
    delay (120)

    Sprite.Hide (sprite2)
    Sprite.Show (sprite1)
    delay (120)
end Player1Punch

proc Player1Walk
    Sprite.Hide (sprite1)

    Sprite.Animate (SpriteWalk1, PicWalk1, x, y, centered)
    Sprite.Show (SpriteWalk1)
    delay (120)

    Sprite.Animate (SpriteWalk2, PicWalk2, x, y, centered)
    Sprite.Hide (SpriteWalk1)
    Sprite.Show (SpriteWalk2)
    delay (120)

    Sprite.Animate (SpriteWalk3, PicWalk3, x, y, centered)
    Sprite.Hide (SpriteWalk2)
    Sprite.Show (SpriteWalk3)
    delay (120)

    Sprite.Hide (SpriteWalk3)
    Sprite.Show (sprite1)
end Player1Walk

proc Player1WalkL
    Sprite.Hide (sprite1)

    Sprite.Animate (SpriteWalkL1, PicWalkL1, x, y, centered)
    Sprite.Show (SpriteWalkL1)
    delay (120)

    Sprite.Animate (SpriteWalkL2, PicWalkL2, x, y, centered)
    Sprite.Hide (SpriteWalkL1)
    Sprite.Show (SpriteWalkL2)
    delay (120)

    Sprite.Hide (SpriteWalkL2)
    Sprite.Show (sprite1)

end Player1WalkL

procedure YANGWALK

    Sprite.Hide (spritewalk1)

    Sprite.Animate (spritewalk2, yangwalk2, x2, y2, centered)
    Sprite.Show (spritewalk2)
    delay (100)

    Sprite.Animate (spritewalk3, yangwalk3, x2, y2, centered)
    Sprite.Hide (spritewalk2)
    Sprite.Show (spritewalk3)
    delay (100)

    Sprite.Animate (spritewalk4, yangwalk4, x2, y2, centered)
    Sprite.Hide (spritewalk3)
    Sprite.Show (spritewalk4)
    delay (100)

    Sprite.Animate (spritewalk5, yangwalk5, x2, y2, centered)
    Sprite.Hide (spritewalk4)
    Sprite.Show (spritewalk5)
    delay (100)

    Sprite.Hide (spritewalk5)
    Sprite.Show (spritewalk4)
    delay (100)

    Sprite.Hide (spritewalk4)
    Sprite.Show (spritewalk3)
    delay (100)

    Sprite.Hide (spritewalk3)
    Sprite.Show (spritewalk2)
    delay (100)

    Sprite.Hide (spritewalk2)
    Sprite.Show (spritewalk1)

end YANGWALK

proc YANGWALKBACK
    Sprite.Hide (spritewalk1)

    Sprite.Animate (spritewalk5, yangwalk5, x2, y2, centered)
    Sprite.Show (spritewalk5)
    delay (100)

    Sprite.Animate (spritewalk4, yangwalk4, x2, y2, centered)
    Sprite.Hide (spritewalk5)
    Sprite.Show (spritewalk4)
    delay (100)

    Sprite.Animate (spritewalk3, yangwalk3, x2, y2, centered)
    Sprite.Hide (spritewalk4)
    Sprite.Show (spritewalk3)
    delay (100)

    Sprite.Animate (spritewalk2, yangwalk2, x2, y2, centered)
    Sprite.Hide (spritewalk3)
    Sprite.Show (spritewalk2)
    delay (100)

    Sprite.Hide (spritewalk2)
    Sprite.Show (spritewalk1)
    delay (100)

    Sprite.Hide (spritewalk1)
    Sprite.Show (spritewalk2)
    delay (100)

    Sprite.Hide (spritewalk2)
    Sprite.Show (spritewalk3)
    delay (100)

    Sprite.Hide (spritewalk3)
    Sprite.Show (spritewalk4)
    delay (100)

    Sprite.Hide (spritewalk4)
    Sprite.Show (spritewalk5)
    delay (100)

    Sprite.Hide (spritewalk5)
    Sprite.Show (spritewalk1)

end YANGWALKBACK

procedure YANGPUNCH

    Sprite.Hide (spritewalk1)

    Sprite.Animate (spritepunch1, yangpunch1, x2, y2, centered)
    Sprite.Show (spritepunch1)
    delay (100)

    Sprite.Animate (spritepunch2, yangpunch2, x2, y2, centered)
    Sprite.Hide (spritepunch1)
    Sprite.Show (spritepunch2)
    delay (100)

    Sprite.Animate (spritepunch3, yangpunch3, x2, y2, centered)
    Sprite.Hide (spritepunch2)
    Sprite.Show (spritepunch3)
    delay (100)

    Sprite.Animate (spritepunch4, yangpunch4, x2, y2, centered)
    Sprite.Hide (spritepunch3)
    Sprite.Show (spritepunch4)
    delay (100)

    Sprite.Hide (spritepunch4)
    Sprite.Show (spritewalk1)

end YANGPUNCH


%*************************************************************************************************
%******************************************** Key Controls ***************************************
%*************************************************************************************************

loop
    Input.KeyDown (chars)
    if chars ('d') and x < 550 then
        x += 15

        Sprite.SetPosition (sprite1, x, y, centered)
        Sprite.SetPosition (SpriteWalk1, x, y, centered)
        Sprite.SetPosition (SpriteWalk2, x, y, centered)
        Sprite.SetPosition (SpriteWalk3, x, y, centered)

        delay (10)
        Player1Walk

    elsif chars ('a') and x > 10 then
        x -= 15

        Sprite.SetPosition (sprite1, x, y, centered)
        Sprite.SetPosition (SpriteWalkL1, x, y, centered)
        Sprite.SetPosition (SpriteWalkL2, x, y, centered)

        delay (10)
        Player1WalkL

    elsif chars (' ') then
        Player1Punch

    elsif chars (KEY_LEFT_ARROW) and x2 > 10 then
        x2 -= 20
        Sprite.SetPosition (spritewalk1, x2, y2, centered)
        Sprite.SetPosition (spritewalk2, x2, y2, centered)
        Sprite.SetPosition (spritewalk3, x2, y2, centered)
        Sprite.SetPosition (spritewalk4, x2, y2, centered)
        Sprite.SetPosition (spritewalk5, x2, y2, centered)
        YANGWALK

    elsif chars (KEY_RIGHT_ARROW) and x2 < 550then
        x2 += 20
        Sprite.SetPosition (spritewalk1, x2, y2, centered)
        Sprite.SetPosition (spritewalk2, x2, y2, centered)
        Sprite.SetPosition (spritewalk3, x2, y2, centered)
        Sprite.SetPosition (spritewalk4, x2, y2, centered)
        Sprite.SetPosition (spritewalk5, x2, y2, centered)

        YANGWALKBACK

    elsif chars ('0') then
        YANGPUNCH
    end if
    View.Update
end loop

Sprite.Free (sprite1)
Sprite.Free (sprite2)
Sprite.Free (sprite3)
Sprite.Free (SpriteWalk1)
Sprite.Free (SpriteWalk2)
Sprite.Free (SpriteWalk3)
Sprite.Free (SpriteWalkL1)
Sprite.Free (SpriteWalkL2)

HeavenAgain




PostPosted: Thu Dec 20, 2007 11:12 pm   Post subject: RE:Sprites ontop of Background

you know for your punch procedures? i think you could just make them into process
example:
code:
procedure YANGPUNCH
.........
end YANGPUNCH

into
code:
process YANGPUNCH
.........
end YANGPUNCH

and call it like fork YANGPUNCH, and do that the same to Player1Punch
try that and see if it helps Rolling Eyes
Lawlly




PostPosted: Thu Dec 20, 2007 11:34 pm   Post subject: Re: Sprites ontop of Background

Na that didn't fix it. All it did was make my program run uber fast. You still cant do things at the same time.
HeavenAgain




PostPosted: Thu Dec 20, 2007 11:48 pm   Post subject: RE:Sprites ontop of Background

UH this might sound a bit weird...... but try making all those procedure (that you use in your main loop) into process....... fork them all and see what happens.............. Neutral i have a feeling its gonna screw up your program though..... other than that.... Rolling Eyes....
Lawlly




PostPosted: Fri Dec 21, 2007 12:05 am   Post subject: Re: Sprites ontop of Background

Yes big screw up o_o lots of processes running ~ ah flashy sprites going wild.


offtopic: With so many problems im having with my own little program my respect for programmers only groes seeing as how much knowledge, patience, time, and thought that they have to go through.
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  [ 13 Posts ]
Jump to:   


Style:  
Search: