Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / "cut" spriteshape

Author
Message
greycheek
8
Years of Service
User Offline
Joined: 13th Mar 2016
Location:
Posted: 1st Jun 2018 23:52
Is it possible to take the shape of a Sprite (especially a complex one) and use it to "cut out" the shape of an another Sprite?
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 2nd Jun 2018 03:30 Edited at: 2nd Jun 2018 03:41
With two images the same could use one image as the cutting outline for another image ie white squares cut black ignore


and could use a function similar to this to get the colors associated at the particular image locations checking every x and y location
the image one might be used to determine what colors etc to cut out from image 2 that you may paste onto image 3



so in effect you are using image one as a mask, the above code will fetch the color from a screen location but it can easily be modified to
fetch the color for a particular image
fubar
greycheek
8
Years of Service
User Offline
Joined: 13th Mar 2016
Location:
Posted: 2nd Jun 2018 13:30
FUBARPK:
You're example is interesting, but I don't think it would work in my case. I want to be able to subtract part of a tiled game board from its entirety, so that the rest of the board can be in a "fog of war". the only way I think that could work is through sprites.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 2nd Jun 2018 14:50
There is a simpler way to create a fog of way - by adding fog.
In your scenario, can you overlay a sprite on the parts that should be invisible?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 2nd Jun 2018 15:12 Edited at: 2nd Jun 2018 15:16
Using a sprite as fog is a great method Batvink
you could use a dithered image like this
http://users.tpg.com.au/subarpk/blackCircle.png


Theres a gradual shading of alpha in the above image and you may need to make your own
i made that one in gimp the idea is I made it much larger than the screen so I could move it
around.with the player


an example of how I used that fog
fubar
greycheek
8
Years of Service
User Offline
Joined: 13th Mar 2016
Location:
Posted: 2nd Jun 2018 17:37
Problem with adding fog is that the fog itself can't be reasonably calculated. I can add together the visibility of each unit in the game (which is different for each) where they stand, into one mass. The rest of the board is the fog.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 2nd Jun 2018 18:05 Edited at: 2nd Jun 2018 18:49
Shaders are a great way of achieving it https://forum.thegamecreators.com/thread/214598 may
have something that can help you in the way of shaders. When I wrote zombie escape I was avoiding using
shaders so I developed in Gimp the black circle effect was easy enough to create and best part it cost me
nothing. If you have a paint program you can load the image into, one that will show how the transparency
was done it would be a good idea to have a look at the black circle in that. If not I thoroughly recommend
GIMP https://www.gimp.org/ its free and is allot like Photoshop apart from the filter range photoshop
has theres not much difference a little harder to use tho

My logic was thinking at the time phones have lots of memory but don't have any built in shader routines in there graphics.
So I figured it was easy to create the effect with a large image 2048 by 2048 in the above. but I broke that rule with the death
routine, I found a lovely ripple effect shader https://forum.thegamecreators.com/thread/214598 and I just setspritecolor …….red

HAHA but that code never got the expected downloads, I think one of the main reasons it is quite a large install
as there is so many images. A new set of tiles for every level pretty much. but you live and learn that was made in time for last
helloween. But I hope the snippets ive been emailing back helps. If your still having issues perhaps share your code
there are some really good gurus who like to help on AppGameKit forums. Who are allot better than I with their coding I just try and help
where I can, I really like to help and I have received allot of help from people in the past and still get help I really love
the AppGameKit forums and one of the main reasons I have stuck with TGC products for so long
fubar
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 3rd Jun 2018 00:40
i'd be interested to hear the results if you do manage to find a solution.
i usually use the method batvink suggests and add fog as sprites to hide the map under.
an example can be seen in my old space project where i cover the entire map with 1 fog sprite and then split the fog sprite(s) into 4 smaller fog sprites as each "fog" is uncovered by a unit (i.e. it comes into a certain distance)... as long as you delete the fog once it reaches a certain size it can generally cope fairly well in terms of speed but it would probably be better to try for a shader if you want something better.

life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 3rd Jun 2018 08:26
I’ve asked for this and related effects on pretty much every questionnaire AppGameKit have sent out. I’d love to see more 2D effects added to AGK.
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
greycheek
8
Years of Service
User Offline
Joined: 13th Mar 2016
Location:
Posted: 3rd Jun 2018 13:50
Solved the problem, but not with single sprites. Works like this:

1 Fill ALL board tiles with "not visible" fog data
2 Fill board tiles that represent what each unit can "see" with "visible" data
3 Add a fog sprite that covers the board for each tile that is not visible, avoiding the tiles that are visible

Although there are hundreds of tiles in the board, this all happens instantly.

Login to post a reply

Server time is: 2024-11-23 20:28:16
Your offset time is: 2024-11-23 20:28:16