Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  i need windowed and not fullscreen  (Read 1978 times)
0 Members and 1 Guest are viewing this topic.
Offline m77

« In padded room »

« Posted 2014-05-04 15:52:20 »

i can run fullscreen fast java gfx with example from Developing Games in Java - David Brackeen
this is good
but i can't make it windowed
this is bad

Developing Games in Java - David Brackeen

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  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
import java.awt.*;
import javax.swing.ImageIcon;
import javax.swing.JFrame;

public class AnimationTest2 {

    public static void main(String args[]) {
        AnimationTest2 test = new AnimationTest2();
        test.run();
    }

    private static final DisplayMode POSSIBLE_MODES[] = {
        new DisplayMode(800, 600, 32, 0),
        new DisplayMode(800, 600, 24, 0),
        new DisplayMode(800, 600, 16, 0),
        new DisplayMode(640, 480, 32, 0),
        new DisplayMode(640, 480, 24, 0),
        new DisplayMode(640, 480, 16, 0)
    };

    private static final long DEMO_TIME = 10000;

    private ScreenManager screen;
    private Image bgImage;
    private Animation anim;


    public void loadImages() {
        // load images
        bgImage = loadImage("images/background.jpg");
        Image player1 = loadImage("images/player1.png");
        Image player2 = loadImage("images/player2.png");
        Image player3 = loadImage("images/player3.png");

        // create animation
        anim = new Animation();
        anim.addFrame(player1, 250);
        anim.addFrame(player2, 150);
        anim.addFrame(player1, 150);
        anim.addFrame(player2, 150);
        anim.addFrame(player3, 200);
        anim.addFrame(player2, 150);
    }


    private Image loadImage(String fileName) {
        return new ImageIcon(fileName).getImage();
    }


    public void run() {
        screen = new ScreenManager();
        try {
            DisplayMode displayMode =
                screen.findFirstCompatibleMode(POSSIBLE_MODES);
            screen.setFullScreen(displayMode);
            //JFrame jf = screen.getFullScreenWindow();
            //screen.restoreScreen();
            loadImages();
            animationLoop();
        }
        finally {
            screen.restoreScreen();
        }
    }


    public void animationLoop() {
        long startTime = System.currentTimeMillis();
        long currTime = startTime;

        while (currTime - startTime < DEMO_TIME) {
            long elapsedTime =
                System.currentTimeMillis() - currTime;
            currTime += elapsedTime;

            // update animation
            anim.update(elapsedTime);

            // draw and update screen
            Graphics2D g = screen.getGraphics();
            draw(g);
            g.dispose();
            screen.update();

            // take a nap
            try {
                Thread.sleep(20);
            }
            catch (InterruptedException ex) { }
        }

    }


    public void draw(Graphics g) {
        // draw background
        g.drawImage(bgImage, 0, 0, null);

        // draw image
        g.drawImage(anim.getImage(), 0, 0, null);
    }

}


removing "screen.setFullScreen(displayMode);" doesn't help
"screen.restoreScreen();" doesn't help too
Offline m77

« In padded room »

« Reply #1 - Posted 2014-05-04 15:58:34 »

i missed u like a desert miss a rainbow
hedgehogs r good
but not u
in my life i had 2 or maybe 3 hedgehogs
Offline m77

« In padded room »

« Reply #2 - Posted 2014-05-04 17:08:59 »

yeah i am lazy
so what
and not just i am lazy to dig the shit
i usually think that if i created things like libraries i would provide a nice simple and working example
with no need to dig the things by myself
btw i wrote pretty cool and short java tutorial for total newbs in russian
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Cero
« Reply #3 - Posted 2014-05-04 18:24:09 »

you youngsters may not know but m77 actually has skill, he made like pseudo 3d shooters and stuff

as to your question m77, it has been way too long since I used Java2D
you say

Quote
removing "screen.setFullScreen(displayMode);" doesn't help

Surprises me... without that there is no command to initiate any screen change... but I dont know what the screenmanager does at all

Offline m77

« In padded room »

« Reply #4 - Posted 2014-05-04 18:50:05 »

SwordsMiner i have a problem that u r a gamer
but i have even more problem with the fact that u r not my facebook follower
even more
u do not do stuffs with me
+ u r 2 young and i don't like your look and voice
Offline philfrei
« Reply #5 - Posted 2014-05-04 19:35:04 »

In that book, Brackeen explicitly decided to cover full-screen games and not windowed mode. He writes about the decision to do so on page 23 of my copy.

If there is going to be a way to fiddle with his code to make it windowed, I think it will be part of the class ScreenManager (referenced in this program sample). I took a look at it, but would have to do some digging (e.g., check definitions of GraphicsDevice, GraphicsEnvironment for starters) to say exactly if and how one could alter the code to make it work for windowed mode. It might be doable.

But if you want to have the animation display in a window, maybe just using a JPanel or JComponent for the display screen makes more sense. As far as I know, most of the "high speed" benefits of using his ScreenManager go away if you decide to put the game in a windowed mode. Maybe animating via Graphics2D and Swing/AWT would be sufficient.

The go-to libraries for high speed graphics these days seems to be LWJGL, and LibGDX which relies on LWJGL wrapper to OpenGL. These can be made to work in a windowed environment.

P.S. You used to have a Milla Jojovich avatar, yes? I'm curious where that photo came from. Was it one of her movies? (Which one?) I've recently become a fan.

P.P.S. Congratulations on recent alcohol avoidance reported on another thread.

"It's after the end of the world! Don't you know that yet?"
Offline m77

« In padded room »

« Reply #6 - Posted 2014-05-04 19:40:38 »

already got throw
just found some simple and working another example
Offline wessles

JGO Wizard


Medals: 67
Projects: 4
Exp: 3 years


Profile picture isn't relevant.


« Reply #7 - Posted 2014-05-04 20:09:04 »

you youngsters may not know but m77 actually has skill, he made like pseudo 3d shooters and stuff

Link? [Filler text so that this is not 90%+ a quote]

Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 136
Projects: 4
Exp: 3 years



« Reply #8 - Posted 2014-05-04 20:17:11 »

The posts about m77 are unnecessary, try talking about the question instead. I'll move the first couple posts to chitchat later.

Offline saucymeatman
« Reply #9 - Posted 2014-05-04 22:37:07 »

i missed u like a desert miss a rainbow
hedgehogs r good
but not u
in my life i had 2 or maybe 3 hedgehogs

SwordsMiner i have a problem that u r a gamer
but i have even more problem with the fact that u r not my facebook follower
even more
u do not do stuffs with me
+ u r 2 young and i don't like your look and voice

M77 has also made several posts unrelated to the topic, but they remain in the thread. But maybe they were warranted or something, but its really hard to follow this thread.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 136
Projects: 4
Exp: 3 years



« Reply #10 - Posted 2014-05-04 22:46:56 »

He was responding to the posts that I moved to chitchat.
Offline ctomni231

JGO Wizard


Medals: 99
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #11 - Posted 2014-05-07 03:21:51 »

If you show me the screen manager, I'll get a solution up for you  Wink

Online BurntPizza
« Reply #12 - Posted 2014-05-07 03:29:55 »

If you show me the screen manager, I'll get a solution up for you  Wink

http://www.brackeen.com/javagamebook/#download

It's in chapter 2.
Pages: [1]
  ignore  |  Print  
 
 

 

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

The first screenshot will be displayed as a thumbnail.

Longarmx (38 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (55 views)
2014-10-14 00:39:48

TehJavaDev (55 views)
2014-10-14 00:35:47

TehJavaDev (44 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!