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 / [STICKY] Some usefull 2D and 3D tools effects and snippets

Author
Message
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 27th Jan 2021 12:42
Thanks scraggle somehow i knew you would be the one to know the simplified math
with your distance squared algorithym does that mean in relation of an object being inside a 10 by 10 grid would it return 100

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 27th Jan 2021 12:53 Edited at: 27th Jan 2021 14:18
Not necessarily but if it was exactly 10.0 units away then it would return 100.0 which is why I said you should check your distance against a squared value instead.

If you are in a fixed 2D grid and can only travel vertically or horizontally then you should use the Manhattan Distance (or Taxi-Cab Distance) check instead.

Manhattan distance is so called because it is the distance you would have to travel on roads in Manhattan which are all horizontal or vertical and you obviously can't travel in a straight line because ... buildings.


Using the example coordinates from the previous post: (0, 0, 1, 2)
GetDistance2D(0, 0, 1, 2)
returns 2.36

GetManhattanDistance(0, 0, 1, 2)
returns 3 because you have to traverse 3 squares (Two vertically plus one horizontally)

There is also the Chebeshev Distance which returns the maximum distance on any axis in a 2D grid.
Because of how it works I prefer to think of it as the MaxGridDistance

Attachments

Login to view attachments
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 29th Jan 2021 22:22
Thanks Scraggle very handy,

Something thats very handy for coders i feel and worth a mention if youve overwritten your source file
doesnt always work tho unfortunately

Step 1. Open Windows Explorer and find the folder where the file was located in.

Step 2. Right-click anywhere inside this folder and select "Properties".

Step 3. Select the "Previous Versions" tab. Look for an earlier version of the overwritten file and restore from it.


fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 6th Feb 2021 21:02 Edited at: 6th Feb 2021 21:24
To determine if you are running in debug (Windows only but there's probably a similar structure in mac i would imagine)
Ortu
DBPro Master
17
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 11th Feb 2021 01:35
Quote: "Something thats very handy for coders i feel and worth a mention if youve overwritten your source file
doesnt always work tho unfortunately

Step 1. Open Windows Explorer and find the folder where the file was located in.

Step 2. Right-click anywhere inside this folder and select "Properties".

Step 3. Select the "Previous Versions" tab. Look for an earlier version of the overwritten file and restore from it.
"


I think you have to have enabled backups for this.

Better yet, use git, preferably with a remote on a separate device and/or location
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 24th Mar 2021 17:14
Another terrain creator
This one may be suitable for those that want a low poly retro feel to a game
No media required
1> w a s d/shift move camera (camera needs work)
2> space saves
the file will save to a location of your choice but you meed a file that exists there first ie dummy.obj
the program will then save dummy.obj and dummy.mtl at that location
3> you may wish to bring into a program like blender to weld close verts etc effectively shrinking the file size
USE AT OWN RISK



fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 24th Mar 2021 17:14 Edited at: 24th Mar 2021 21:23
Another terrain creator
This one may be suitable for those that want a low poly retro feel to a game
No media required
1> w a s d/shift move camera (camera needs work)
2> space saves
the file will save to a location of your choice but you meed a file that exists there first ie dummy.obj
the program will then save dummy.obj and dummy.mtl at that location
3> you may wish to bring into a program like blender to weld close verts etc effectively shrinking the file size
USE AT OWN RISK



fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 11th Apr 2021 11:36 Edited at: 13th Apr 2021 13:42
This program may be used display paintball splats/bullets on an object etc



ps shader


vs shader

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 11th Apr 2021 11:36 Edited at: 11th Apr 2021 11:38
some test images for the above




fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk

Attachments

Login to view attachments
CumQuaT
AGK Master
14
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 28th Apr 2021 10:49
I just finished going through all of these. Absolutely amazing library of resources, mate, thank you for sharing them!
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 28th Apr 2021 13:51
your very welcome

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 10th Feb 2023 02:42
The below program speed tests various methods of flipping an object as follows:
1 using a memblock with getcolour commands
2 using a shader without using draw calls (hence if you was to save the image the changes would not be seen)
3 using Kevin Pocones suggestion and modifying the memblock to retrieve an integer instead of 3 calls to get colours
4 adds the time before with a shader to retrieving the image

not being aware of the command SetSpriteFlip ( iSpriteIndex, horz, vert ) i created the following code
which i hope will help people have a better understanding of memblocks and shaders ive included a test image
fubarpk
https://fubarpk.itch.io/
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 19th Feb 2023 14:49
A new take on "Hello World" with a kind of matrix effect
fubarpk
https://fubarpk.itch.io/
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 21st Mar 2023 13:04 Edited at: 21st Mar 2023 13:45
Thought this was handy to share it dumps a heap of characters as bytecode to a text file
and loads the information into a picture this can then be retrieved individually, each pixel
may represent 4 characters so it could be used as an alternative to loading and storing
large amounts of text. example a 128*128 pixel image could represent 128^4 * 128^4
characters and also a method of passing the text handling to the video card


a look up method would have to be used ie you could search for a string between two chr(13) characters and retrieve a line and its position pointer
for example
fubarpk
https://fubarpk.itch.io/
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 9th Apr 2023 21:51
With some help from Phaelax the below code was created


what was discovered is that lookupRGBAatXY(x,y) and the lookupRGBAatImageXY(img2,x,y) will return different values
this is due to one grabbing a pixel to convert and the other looking up in the image directly.

The program does take a bit to load first time and once you have done so much can be commented out but i wanted to add
getStringFromImage(img2,32,1) will grab a string similar to trim string between delimetered text but will almost hang the program
if there isnt the string its searching for when its in the main loop hence why its commented out
fubarpk
https://fubarpk.itch.io/
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 17th Apr 2023 18:55 Edited at: 17th Apr 2023 18:56
2D basic outline sprite shader


the ps shader code
fubarpk
https://fubarpk.itch.io/
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 9th May 2023 09:28 Edited at: 9th May 2023 13:01
A simple dithering effect shader
using modulas to only draw odd pixels

dither.ps


to use its just a matter of
fubarpk
https://fubarpk.itch.io/
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 9th May 2023 14:34
and using the dither and adding a glow effect

ditherwithglow.ps


leaving these two constants to adjust in program
SetShaderConstantByName(shader,"colour",1,0,0,1) ///gives a red glow around edge
SetShaderConstantByName(shader,"pixels",0.76,0.84,0.73,1) //dithered gold effect
fubarpk
https://fubarpk.itch.io/
Resourceful
10
Years of Service
User Offline
Joined: 29th Jan 2014
Location: every ware
Posted: 29th Jul 2023 14:26 Edited at: 29th Jul 2023 14:51
HI

I would like to know

why 2 files "ps shader" and "vs shader" are needed to do
a similar affect as DBP only needs one needs one file ?

much thanks to all for creating examples

Login to post a reply

Server time is: 2024-11-23 08:18:29
Your offset time is: 2024-11-23 08:18:29