Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (794)
Games in Android Showcase (234)
games submitted by our members
Games in WIP (864)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2 3 ... 10
 1 
 on: 2019-07-19 16:14:22 
Started by pavul - Last post by pavul
I remember someone says that canvas or graphics context was powerful enough, however did not wanted to make another library like Almas is currently doing, I handle the opacity with alpha property pretty well, however when I want to change the color sprite for something red or yellow ( when I hit the sprite ) I think it can be done with blend, I was setting the blend effect to canvas but everything is a single node or a sole canvas in this case, so the blend effects don't overlap 2 nodes like the other examples have.

what I what to achieve for now is blend the sprite with some specific color and put a black surface on top and then make the effect of a flashlight just to make transparent the part where the flashlight is, I was thinking to create a black rectangle, put the flashlight on top, and with the pixel writer of the canvas make all flashlight pixels transparent, but I think that can be overwhelming.

 2 
 on: 2019-07-19 16:05:03 
Started by pavul - Last post by Shatterhand
@philfrei That does work for normal Nodes, but things are a bit different for the Canvas.

@pavul Any reason why you use a Canvas? That's slower and not really better to handle IMO.
Anyway, you can set BlendModes: https://openjfx.io/javadoc/11/javafx.graphics/javafx/scene/effect/BlendMode.html in your GraphicsContext: https://openjfx.io/javadoc/11/javafx.graphics/javafx/scene/canvas/GraphicsContext.html

Perhaps that would help you? E.g. drawing a mask image with a certain blend mode to create a fade effect, or light effect, or whatever.

Cheers

 3 
 on: 2019-07-19 02:29:52 
Started by pavul - Last post by philfrei
I've only done a little bit with blending. I did this by changing the opacity property of various graphics being shown as ImageViews. Opacity is a property of Node, though, so it should be possible to make any Node opaque/transparent.

Can you show some code for what you tried?

 4 
 on: 2019-07-18 05:12:36 
Started by pavul - Last post by pavul
Hello everyone, its me again after a year, so i made progress using JavaFX for game Development as hobby, and basically what i am doing is putting a canvas in a node and that node in the stage, all the game is processed on that canvas, however, i would like to implement some blend effects, but so far all examples that exist online are using different nodes, does anyone knows if its possible to use blend using a sole canvas ( node ) instance?, i tried to make this with no result until now, thanks in advance.

 5 
 on: 2019-07-18 05:07:38 
Started by pavul - Last post by pavul
i dont know if there are something like this in the forum( just let me know in that case ), here are some functions i created for a project i am working and are usefull for game dev, i am using JavaFX with Canvas only, dunno if they work on swing, any CC or sugestion will gradly received

CLAMP
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
/**
 * if value is mayor than max value, max value will be returned,
 * if value is minor than min value, min value will be returned,
 * if value is in range between mayor and minor values, then
 * value will be returned
 * @param value
 * @param minValue
 * @param maxValue
 * @return value will never falls below minValue or goes over maxValue
 */

public static float clamp( float value, float minValue, float maxValue )
{
    // value must be between minValue and maxValue
    return (value > maxValue) ? maxValue : (value < minValue) ? minValue : value;
}


LERP
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
/**
 * this function creates linear interpolation depending on argument t,
 * which is the percentage of v0 until v1
 * @example lerp(0, 10, 0.5): will return 5.0, because is the middle ( 0.5 ) between 0 and 10
 * @param v0
 * @param v1
 * @param t
 * @return
 */

public static float Lerp(float v0, float v1, float t)
{
    return (1-t)*v0 + t*v1;
}



LENGHT_DIR_X
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
/**
 * returns X position of the vector determined by length and angleDirection
 * <b>NOTE: you must add to this value to originX where will be added this vector
 * for example sprite.getX()+lengthdirX( 100, 45 )</b>
 * @param length
 * @param angleDirection
 * @return
 */

public static float lengthdirX( float length, float angleDirection )
{
return (float)Math.cos( angleDirection * (Math.PI/180) ) * length;
}


LENGHT_DIR_Y
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
/**
 * returns Y position of the vector determined by length and angleDirection
 * <b>NOTE: you must add to this value to originY where will be added this vector
 * for example sprite.getY()+lengthdirY( 100, 45 )</b>
 * @param length
 * @param angleDirection
 * @return
 */

public static float lengthdirY( float length, float angleDirection )
{
return (float)Math.sin( angleDirection * (Math.PI/180) ) * length;
}


 6 
 on: 2019-07-18 05:01:07 
Started by pavul - Last post by pavul
just recently implemented this in some project i am working, there are some examples of this in stackoverflow but not especifically with a canvas ( i am not 100% sure about that), when this method is called it will create a  UUID.png file on the root of the project, any CC or sugestiong will be gladly received.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
/**
 * this takes an snapshoot of the current game and is stored on the
 * root where the game resides in PNG format
 * @param  canvas
 * @param width width of the image
 * @param height height of the image
 */

public static void takeSnapshot(Canvas cnavas, int width, int height)
{
    WritableImage wim = null;//new WritableImage(width, height);
   
   try
   {
      String fileName = UUID.randomUUID().toString();
   
      File file =  new File( fileName+".png" );
      wim = gm.snapshot( null, null );
      ImageIO.write( SwingFXUtils.fromFXImage( wim ,null ), "png", file );
     
   }
   catch(IOException ioe)
   {
       System.err.println( "::: error when creating snapshot "+ioe.getMessage() );
   }
}//

 7 
 on: 2019-07-17 16:28:15 
Started by BurntPizza - Last post by TritonDreyja
More tweaks to world generation have been made. Caves have a more organic form and whatnot.
Next is tweaking  my lighting engine to improve performance.

 8 
 on: 2019-07-17 08:08:31 
Started by BurntPizza - Last post by Guerra2442
After my 3-month break I'm back with improved contact shadows, this time is an hybrid ray-march instead of a pure ray-tracer.







Still needs improvements but it's way better than the previous one.

 9 
 on: 2019-07-14 01:46:40 
Started by TritonDreyja - Last post by TritonDreyja
Been working on TF for 12 hours today, and solved many problems.

Colored lighting now works, terrain generation algorithm has been reconfigured, and libGDX particles now work with the game properly Smiley


Click to Play

 10 
 on: 2019-07-13 23:42:17 
Started by RyanAlbano - Last post by RyanAlbano
Project has been migrated from ANT script to a Gradle project.

Pages: [1] 2 3 ... 10
 
hadezbladez (3132 views)
2018-11-16 13:46:03

hadezbladez (1142 views)
2018-11-16 13:41:33

hadezbladez (3101 views)
2018-11-16 13:35:35

hadezbladez (624 views)
2018-11-16 13:32:03

EgonOlsen (3911 views)
2018-06-10 19:43:48

EgonOlsen (4389 views)
2018-06-10 19:43:44

EgonOlsen (2617 views)
2018-06-10 19:43:20

DesertCoockie (3436 views)
2018-05-13 18:23:11

nelsongames (3556 views)
2018-04-24 18:15:36

nelsongames (4606 views)
2018-04-24 18:14:32
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!