Author Topic: How to make transparent a random area of a sprite before DrawSprite?  (Read 3151 times)

Offline Serge

  • Mc. Print
  • *
  • Posts: 6
    • View Profile
Hi all,

I am trying to make transparent some random areas of a image before draw it to the back buffer. I saw the functions GetPixel and SetPixel but I think they work only over the back buffer.  I would need to be able to modify the image before draw it, so the areas that I randomly defined transparent will not be drawn.

Basically what I need is:

-Load an image in a sub-buffer where I could be able to read the pixels and modify them.
-Keep this image and the modifications in memory, since I would need to use it again.
-Redefine the DrawSprite, so I could be able to draw in the buffer only the areas that I required.

Is it possible?

Thanks so much and regards

Serge
www.tiptapgames.com

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10746
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Not really.
You could try to access the sprite's pixel with CREATESCREEN and then USESCREEN to draw on the sprite.
What are you trying exactly?

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1787
    • View Profile
    • Homepage
You could also draw the sprite with polysprites, only the parts that you don't want transparent. I'm no expert on this command but I think it is possible :-)

Offline Serge

  • Mc. Print
  • *
  • Posts: 6
    • View Profile
Hi,

I need to have 2 images, one as backgrond and other one that at the begining does not have any transparency, so I will draw a irregular area on this image and I need to make transparent only this area, so it will be like a window where you can see the background.

I hope it clarifies.

Thanks again and best regards.

Serge
www.tiptapgames.com

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1787
    • View Profile
    • Homepage
Ok, if I understand you correctly I would only use one picture and draw the parts I want visible with POLYVECTOR.

POLYVECTOR has four coordinates for each point you draw, split the area in triangles, drawing each point beginning from the edges of the screen into the middle, first pair of coordinates are on the drawing surface, the second pair is from the source so you are mapping the image onto the screen. Hope you understand what I mean :-)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10746
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Yes, that or drawing the "holes" with drawrect.

There was some proof of concept for a lemmings / Worms IIRC...
(searches)

Hm. I can't find it anymore.

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4158
  • On the shoulders of giants.
    • View Profile
    • My Apps
Here is a very limited "Lemmings" style deformable landscape. It draws a random landmass (that's larger than the visible screen) that can be destroyed by pressing the left mouse button. Scroll the landscape with LEFT and RIGHT cursors.

http://www.iprice.remakes.org/my_stuff/lemmings.rar

[edit, Kitty]
Added the file as an attachment, too (safety)
Search keywords:
Lemmings,lemmings,worms,Worms,holes,

[attachment deleted by admin]
« Last Edit: 2010-Feb-11 by Kitty Hello »
I came. I saw. I played.

Offline Serge

  • Mc. Print
  • *
  • Posts: 6
    • View Profile
 =D That's exactly what I needed, thanks so much for your help!!

Serge
www.tiptapgames.com

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10746
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
did you try if that's fast enough on the iPhone? Would be interested...

Offline Serge

  • Mc. Print
  • *
  • Posts: 6
    • View Profile
Mhh, not yet, but I will make some performance test and let you know the results

Best regards

Serge
www.tiptapgames.com