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

Username:   Password: 
 RegisterRegister   
 Pic Transparency, Collision detection. Need major help.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
aspire




PostPosted: Thu Jan 10, 2008 11:15 am   Post subject: Pic Transparency, Collision detection. Need major help.

Hey everyone. Well the time has come for a final term project. My goal is to make a game. I have already hit a great big hard wall :/. I am really lost, I have no idea what to do, and no one has been able to help me in my class.

I am in need of help with getting my Picture to become transparent and to get my Collision Detection right. Also, I know my code is EXTREMLY messy. So if anyone is willing to help me get this working and cleaned up, I will be a very happy camper Very Happy.

The picture is attached.

Thanks very much,
Aspire

Turing:
var sprite_x, sprite_y : int
var sprite_chars : array char of boolean
var sprite_pic : int := Pic.FileNew ("sprite3.jpg")
var sprite_left_width : int := Pic.Width (sprite_pic)
var sprite_left_height : int := Pic.Height (sprite_pic)
var obstacle1_x, obstacle1_y : int
var points : int
var lastMoved : int := 0
var timeRunning : int
% Sprite Function
var delayTime : int
var Distance_between_centres : real
var spriteID : int
Pic.SetTransparentColor (sprite_pic, white)
Pic.Draw (sprite_pic, 2, 2, picMerge)
%spriteID := Sprite.New (sprite_pic)
%Sprite.Show (spriteID)

obstacle1_x := Rand.Int (20, maxx)
obstacle1_y := Rand.Int (20, maxy)
clock (timeRunning)
lastMoved := timeRunning - 2001

setscreen ("offscreenonly")
sprite_x := 200
sprite_y := 100
points := 0


colorback (brightred)
loop
    cls
    locate (5, 1)
    put points
    clock (timeRunning)
    if timeRunning - lastMoved > 2001 then
        obstacle1_x := Rand.Int (20, maxx)
        obstacle1_y := Rand.Int (20, maxy)
        lastMoved := timeRunning
    end if

    Input.KeyDown (sprite_chars)

    if sprite_chars (KEY_UP_ARROW) then
        sprite_y := sprite_y + 5
    end if
    if sprite_chars (KEY_DOWN_ARROW) then
        sprite_y := sprite_y - 5
    end if
    if sprite_chars (KEY_RIGHT_ARROW) then
        sprite_x := sprite_x + 5
    end if
    if sprite_chars (KEY_LEFT_ARROW) then
        sprite_x := sprite_x - 5
    end if

    drawfilloval (obstacle1_x, obstacle1_y, 15, 15, 8)

    if sqrt ((40 + sprite_x - obstacle1_x) ** 2 +
            (sprite_y + 40 - obstacle1_y) ** 2) < 60 then
        points := points + 1
    end if

    Pic.Draw (sprite_pic, sprite_x, sprite_y, picCopy)
    %drawbox (sprite_x, sprite_y, boxx, boxy, 3)
    Sprite.SetPosition (spriteID, sprite_x, sprite_y, false)
    View.Update
    delay (25)


end loop





Sprite.jpg
 Description:
 Filesize:  31.79 KB
 Viewed:  87 Time(s)

Sprite.jpg


Sponsor
Sponsor
Sponsor
sponsor
Randolf Nitler




PostPosted: Thu Jan 10, 2008 12:03 pm   Post subject: Re: Pic Transparency, Collision detection. Need major help.

I don't understamd, you want your pick to slowly blur until you can't see it on the screen?
Tony




PostPosted: Thu Jan 10, 2008 12:10 pm   Post subject: RE:Pic Transparency, Collision detection. Need major help.

Are you talking about transparency (no white background) or alpha-transparency (see-through image)?

alpha-transparencies would be computationally intensive, by Turing's standards.

to remove just white background, you should be using picMerge mode when drawing inside your loop (just like you did in the initial setup), not picCopy.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Zampano




PostPosted: Thu Jan 10, 2008 3:26 pm   Post subject: Re: Pic Transparency, Collision detection. Need major help.

Trying to use pictures (even simple sprites) during gameplay in Turing is a waste of time. That is the short and long of it.
ericfourfour




PostPosted: Thu Jan 10, 2008 5:30 pm   Post subject: RE:Pic Transparency, Collision detection. Need major help.

Replace picCopy with picMerge. You should consider making the picture a .bmp file. JPEGs have poor qualtiy when using picMerge.
Tony




PostPosted: Thu Jan 10, 2008 5:41 pm   Post subject: RE:Pic Transparency, Collision detection. Need major help.

depends on the quality of the image. Bitmaps are lossless, but JPEGs are often compressed. If the compression results in artifacts on the background area, there will be pixels that don't render white, so those will not merge properly.

you could turn compression off though, when saving the image.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: