Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / JavaFX / Re: Some JavaFX game templates. on: 2009-04-26 07:25:41
How GoldenRed walk.

I use Timer - standard animation JavaFX construction. However I do
not really use it as it is intended to be used, but instead just for
clocking, switching off thing I do not understand yet like interpolate...

For me it is just thing which run certain code in certain time:
-----------------------------------------------------------------------------------

var walkForwardRate = 10;
def walkForwardTimer: Timeline = Timeline {
    repeatCount: Timeline.INDEFINITE
    rate: bind walkForwardRate
    interpolate: false
    keyFrames: [
        KeyFrame {
            time: 1s
            action: function() {
                goldenRedX += 10;
                goldenRed = 1;
            }
        }
        KeyFrame {
            time: 2s
            action: function() {
                goldenRedX += 10;
                goldenRed = 0;
                walkForwardTimer.stop();
            }
        }
    ]
}
-----------------------------------------------------------
As you may see I just change two variables -
goldenRed - which defines picture visible in corresponded ImageView (which I bind to golden Red)
goldenRedX - which defines image horizontal position.

How it will be painted - not my business, somehow, best possible, way using
hardware acceleration or something it will be drawn by JavaFX

Now to trigger this walk - I use onKeyPressed event function:
---------------------------------------------------------------
Stage {
    title: "GoldenRed"
    width: 800
    height: 320
    scene: Scene {
        content: [
            Rectangle {
                fill: Color.rgb(205, 225, 255);
                width: 800
                height: 160
            }
            gameFieldView
            Rectangle {
                opacity: 0
                focusable: true
                width: 800
                height: 350
                onKeyPressed: function(ke: KeyEvent){
                    if (ke.text == "Right") {
                        walkForwardTimer.play();
                    }
                }
            }
        ]
    }
}
--------------------------------------------------------------------------
It just starts this timer and timer stop itself at the end.
If I need to interrupt this timer because different key was
pressed - I just do:
--------------------------------------------------------------------------
walkForwardTimer.stop();
--------------------------------------------------------------------------
I also may just pause it.

Regards, Vassili.
2  Java Game APIs & Engines / JavaFX / Re: Some JavaFX game templates. on: 2009-04-26 06:20:03
Same idea for Lines game, but I bind entire game array to image view.
Each cell binded to corresponded ImageView and also each has
MousePressed event:
--------------------------------------------------------------------------------

def gameFieldView: Node =
Group{
    content: [
        for ( x in [0..8]) {
            for ( y in [0..8]) {
                ImageView {
                    x: x * 33 + 1;
                    y: y * 33 + 1;
                    image: bind gameImages[ gameField[ x + (y * 9)] ]
                    onMousePressed: function(me: MouseEvent){
                        print( "cell {x}, {y} selected");
                    }
                }
            }
        }
    ]
};
-------------------------------------------------------------------------------

All I need to do now - just work with array itself and all changes will
be on the screen right away drawn not by me but JavaFX with it smart
effective etc graphic engine.

This is all simple and elegant beauty of binding.

Again I am not an multi media guy, but very enthusiastic about JavaFX
rapid development side, same as for scripts but with full strength and
performance of Java behind with all this hot spot magic...

Regards, Vassili.
3  Java Game APIs & Engines / JavaFX / Some JavaFX game templates. on: 2009-04-26 06:07:49
Well, this is not how to do this best I guess, this is how I do this,
hope it will be helpful:

For NetBeans -

I put images in Pictures subdirectory in <Project>/src/<package> directory.
Place where Main.fx source code located.

Images handling:
--------------------

def goldenRedImages: Image[] =
for ( name in [
        "gr001.gif",
        "gr002.gif",
        "gr003.gif",
        "gr004.gif",
        "gr005.gif",
        "gr006.gif",
        "gr007.gif",
        "gr008.gif"
    ])
    Image {
        url: "{__DIR__}Pictures/{name}"
}

def goldenRedDX = [ 0,  0, 14, 10, 30, 14, 46, -13];
def goldenRedDY = [ 0,  0,  2,  4, 15  15, 10,   8];
--------------------------------------------------------------------------------
DX  and DY is horizontal and vertical coordinates shifts to line up pictures.

Then I define game view where this images will be seen:
------------------------------------------------------------------------------
def gameFieldView: Node =
Group{
    content: [
        ImageView {
            x: bind 300 + goldenRedDX[ goldenRed ] + goldenRedX
            y: bind 40 + goldenRedDY[ goldenRed ] + goldenRedY
            image: bind goldenRedImages[ goldenRed ]
        }
    ]
};
-----------------------------------------------------------------------------------
And this is all what I need to do for drawing. If I need to
change picture seen in this view only thing to do - change
variable goldenRed - because it is binded to this image view
JavaFX will take car of all drawing for me.

I should not worry about clearing previous picture, repainting
new, synchronizing it with other pictures and with screen updates...

I will only in this case change
goldenRed - which define picture for me (and shifts)
goldenRedY - Vertical coordinates
goldenRedX - Horizontal coordinates

That's it. Once I define this GameField, I may foget about all
representation and focus on the game play itself.

Regards, Vassili.
4  Java Game APIs & Engines / JavaFX / Re: JavaFX game - GoldenRed (half baked) on: 2009-04-21 05:34:56
I fixed Keyboard handling - it turns out it was bug in Windows, and I should not really have any keyboard events...
Now with:

            Rectangle {
                opacity: 0
                focusable: true
                fill: Color.rgb(100, 100, 100)
                width: 800
                height: 350
                onKeyPressed: function(ke: KeyEvent){
                    if (ke.text == "Right") {
                        walkForwardTimer.play();
                    } else if (ke.text == "Left") {
                        walkBackwardTimer.play();
                    } else if (ke.text == "Space") {
                        hit();
                    }
                }
                onMousePressed: function(me: MouseEvent){
                    hit();
                }
            }

It should work on Mac too. Can somebody check this, please?

...Seems like Chrome working pretty well with this game...

Thanks, Vassili.
5  Java Game APIs & Engines / JavaFX / Re: JavaFX game - GoldenRed (half baked) on: 2009-04-19 09:50:59
New update - just rapidly developed another type of Enemy - roboBear...

Today I did object oriented background and object oriented Enemies out of simple working prototype. I am not yet hit all this multymedia staff, but it terms of rapid development JavaFX really does work. For now I think I spend total 3 days programming - last Weekend and today and it going pretty fast.

Thanks, Vassili.
6  Java Game APIs & Engines / JavaFX / Re: JavaFX Lines game. on: 2009-04-19 06:31:55
It is working on Mac for sure. I do not have details (I do not have Mac myself) but friend of mine has no problem with this game.

Thanks, Vassili.
7  Java Game APIs & Engines / JavaFX / Re: JavaFX Lines game. on: 2009-04-18 23:49:24
I guess it is some download error - you may check java console.
What is you platform?

Thanks, Vassili.
8  Java Game APIs & Engines / JavaFX / Re: JavaFX game - GoldenRed (half baked) on: 2009-04-18 23:47:53
Keys don't work...and where are the FX? Is this all, Java FX can deliver?

Well, yes this is just a fraction of what is capable for, but I am just having fun even with this.

I am programming on JavaFx probably for a week now and way behind all the greatest and latest
Multimedia-3D-Video-Audio... whistles and blowers what it have.

However I guess this exercise demonstrate major JavaFX feature (at least for me) - rapid development.
I wrote Lines Game in a day. This one few days over weekends and mostly it is drawing then programming.

To me this rapid development is key feature of JavaFX and it does play this way very well so far. As
you all may see on this two humble examples...

Regards, Vassili.
9  Java Game APIs & Engines / JavaFX / Re: JavaFX game - GoldenRed (half baked) on: 2009-04-18 22:18:46
Add few pines - made forest...

Thanks, Vassili.
10  Java Game APIs & Engines / JavaFX / Re: JavaFX game - GoldenRed (half baked) on: 2009-04-18 07:55:06
I have FireFox and if focus is in applet - if I click on it first, keys does work. However, if I change window and then go back it does not work.

Thanks, Vassili.
11  Java Game APIs & Engines / JavaFX / Re: JavaFX Lines game. on: 2009-04-18 06:36:40
I made more relaxed version - less colors:

http://playground.sun.com/~vasya/LinesGameEasy.html

It is colorNum in html code defines number of color (from 2 to 6):

<script>
    javafx(
        {
              archive: "LinesGame.jar",
              colorNum: 5,
              width: 313,
              height: 367,
              code: "linesgame.Main",
              name: "LinesGame"
        }
    );
</script>


I guess you may copy part of html and jnlp to put it in your own page with your own number of colors
(if 5 is too much).

Thanks, Vassil.

P.S. Be carefull it is very addicted - back in 1990 this game was disaster for every offices back in USSR
which has IBM PC.
... I am wondering how it contributed into USSR collapse which happened exactly same time...
12  Java Game APIs & Engines / JavaFX / JavaFX game - GoldenRed (half baked) on: 2009-04-18 06:22:44
This one is "under development" yet.

http://playground.sun.com/~vasya/GoldenRed.html

Thanks, Vassili.
13  Java Game APIs & Engines / JavaFX / JavaFX Lines game. on: 2009-04-18 05:42:31
Game:

http://playground.sun.com/~vasya/LinesGame.html

20 years old Russian Game - Lines (originally designed 1990 for DOS by some lady
who name I forgot and can not find now). First Java game I wrote 1995 on Java (it
was Java alpha at that time).

Now I made it in Java FX.

Play - line up 5 balls same color, then they disappear. Each step it generates 5
more Randomly, until field full.

Thanks, Vassili.

P.S. Click on ball to select it, click on space to move selected ball to it (if there is free path).
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (24 views)
2014-07-24 01:59:36

Riven (24 views)
2014-07-23 21:16:32

Riven (18 views)
2014-07-23 21:07:15

Riven (21 views)
2014-07-23 20:56:16

ctomni231 (50 views)
2014-07-18 06:55:21

Zero Volt (45 views)
2014-07-17 23:47:54

danieldean (36 views)
2014-07-17 23:41:23

MustardPeter (39 views)
2014-07-16 23:30:00

Cero (55 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!