Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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] 2
1  Games Center / WIP games, tools & toy projects / Re: Squares on: 2013-05-13 13:09:42
Looking good!

What are your future plans for the game?
2  Game Development / Game Play & Game Design / Re: Smooth screen scrolling? on: 2013-05-11 01:23:04
Ok i solved the problem with the screen now not jumping.. But i came with another thought to mind..

Now if i want every keypress to lets say go 10 pixels in the direction the key was pressed.. The drawing looks kind of laggy when the drawing is done that way..

Does anyone have suggestions for  this?
Im using a player velocity of 10.. so doing like this: screenVelocityX += playerVelocity


P.S. Thanks to Oskuro for the good idea of drawing everything to an image then drawing the image to the screen.. It helped me out.

EDIT:
Solved that one too by removing the timer for movement and then decreasing the velocity. Thanks agian everyone who spent time helping!
3  Game Development / Game Play & Game Design / Re: Smooth screen scrolling? on: 2013-05-10 20:04:29
Upgraded my code to this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
   public void drawLevel(Graphics g2d, int screenX, int screenY){
      drawX = 0; //X cordinate for the map to draw at
     drawY = 0; //Y Cordinate for the map to draw at
     
      for(int y = screenY; y < screenY + 10; y++, drawY += 63){
         for(int x = screenX; x < screenX + 13; x++, drawX += 63){
            switch(level1[x][y]){
            case 1:
               levelg2d.drawImage(grass, drawX, drawY, 63, 63, null);
               break;
            case 2:
               levelg2d.drawImage(water, drawX, drawY, water.getWidth() * imageScale, water.getHeight() * imageScale, null);
               break;
            case 0:
               levelg2d.drawImage(temp, drawX, drawY, temp.getWidth() * imageScale, temp.getHeight() * imageScale, null);
               break;
            }
         }
         drawX = 0; //Resets the X cord to draw at for the next line
     }
     
      g2d.drawImage(mapRenderImage, 0, 0, 800, 600, null);
   }


While the mapRenderImage is initiated together with the levelg2d in the class initialization method like this:
1  
2  
mapRenderImage = new BufferedImage(800, 600, BufferedImage.TYPE_INT_ARGB);
      levelg2d = mapRenderImage.createGraphics();


This did not make any difference in the game.. When movement is happended for example: if Player press "D" do screenX++; then i put it into the parameters to drawLevel method.. Maybe im overthinking this and thats why i cannot see the easy solution.. But it still makes every click "jump" 63 pixels everytime i want to move the screen..

EDIT:
I know 100% sure this problem is appearing just because im using the drawX and drawY in the levelg2d.draw to get the tiles lined up correctly and not intersecting eachother in the top left. But i cannot find anything to replace it with.. Sad
I know thats the reason :S

For people who are trying to help me here, screenX and screenY is the cordinates of the top left corner of the screen that should be visible. I increment it when the player presses a movement button.. Example: screenX++;
4  Game Development / Game Play & Game Design / Re: Smooth screen scrolling? on: 2013-05-10 13:32:04
The map rendering is not a problem.. My map is rendered as it should.

My problem here is that when the player walks the screen moves with 64 pixels each time u press a move button. Think how movement is done in the old pokemon games.

The method i posted in the first post is my render method which is called in the update method and is a part of the game loop.

My goal is to make movement smooth like instead of jumping 64 pixels each time render is called jump maybe 1 pixel so movement gets more free.

Understand me?
5  Game Development / Game Play & Game Design / Re: Smooth screen scrolling? on: 2013-05-10 11:14:39
A quick glance at your code makes me suggest it's because you're adding a tiles' width each step.

1  
, drawX += 63){


If it was incrementing by 1 each step, it would go smoothly.

That clumps up all my tiles in the top left corner.. I tried changing it to drawX += 1 and it wont draw the map just place all the tiles in the top corner.

Theese images im drawing is 7*7 tiles but im scaling them up to 63*63.
Reason i put the drawX+= in the for loop was to make the tiles not like draw on top of eachother since x is just incremented with 1 and 1 cordinate compared to 63 wont work  if u know what i mean..
I just suck at explaining.. Hope you understand me :S

Are you sure i dont need float variables to do this task im after?
6  Game Development / Game Play & Game Design / Smooth screen scrolling? on: 2013-05-10 11:05:03
Hello guys,

I cannot figure out how to move from here, I kind of placed myself in a bad position..

Right now when moving in my game it moves with 1 tile per move, The tiles are 64*64 so it looks realy stupid when i want smooth movement. What i mean with smooth movement is that i want my map to be able to draw a half tile and not only whole tiles.

Here is my current code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
   public void drawLevel(Graphics g2d, int screenX, int screenY){
      drawX = 0; //X cordinate for the map to draw at
     drawY = 0; //Y Cordinate for the map to draw at
     
      for(int y = screenY; y < screenY + 10; y++, drawY += 63){
         for(int x = screenX; x < screenX + 13; x++, drawX += 63){
            switch(level1[x][y]){
            case 1:
               g2d.drawImage(grass, drawX, drawY, grass.getWidth() * imageScale, grass.getHeight() * imageScale, null);
               break;
            case 2:
               g2d.drawImage(water, drawX, drawY, water.getWidth() * imageScale, water.getHeight() * imageScale, null);
               break;
            case 0:
               g2d.drawImage(temp, drawX, drawY, temp.getWidth() * imageScale, temp.getHeight() * imageScale, null);
               break;
            }
         }
         drawX = 0; //Resets the X cord to draw at for the next line
     }
   }


The screenX and screenY is incremented using screenX++; in the player move methods.
the scrolling is working but i just cannot figure out how to make the scrolling smooth and not only moving tile per tile.

I thought of change it all to floats but wouldn't that mess with my 2D array?
Also i cannot draw the whole array since its a big map of 500 tiles so i need to draw only whats on the screen.
7  Game Development / Game Play & Game Design / Re: Big World vs Random Generated World on: 2013-05-09 09:03:54
When i posted yesterday i was realy tired. Forgive my ignorance.
Reason i didn't divide by 1000 is that all screen were green from grass... I guess that was the point, I will play more with this today.
8  Game Development / Game Play & Game Design / Re: Big World vs Random Generated World on: 2013-05-08 22:01:25
In his example he uses:
1  
SimplexNoise.genGrad(mapSeed);


What is it i would put in here? How does "seeding" work? What is it i want in there?

EDIT i figured it out myself..

Though i found another issue with my progress..
When i wanted to use this noise to create maps the maps doesn't actualy make sense.. The water and ground is just scattered all over the map there is no cordination or real terrain that is getting generated it all is just mashed up..
How would i solve this?

This is the code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
double value = SimplexNoise.noise(x , y);
            System.out.println(value);
           
            if(value >= 0){
               
               if(value <= 0.8f){
                  level1[x][y] = 1;
               }
               else if(value <= 0.1f){
                  level1[x][y] = 0;
               }
            }
            else{
               level1[x][y] = 2;
            }

level1 x y = 1 means green, 2 means blue, 0 means the magenta square i created.

And here is an image:
9  Game Development / Game Play & Game Design / Re: Big World vs Random Generated World on: 2013-05-06 21:45:06
What if i wanted lets say use it to create an 2D island for a 2D top down rpg?

And then also having it help me create different kind of terrains like desert, woods, stones?
Instead of your example of creating hills (Which was not bad at all im realy happy with the knowledge you share)
Create something like this:

That is only an image i found on google to explain what im thinking, Hope u get an idea of what im trying to do Smiley
10  Game Development / Game Play & Game Design / Re: Big World vs Random Generated World on: 2013-05-06 17:42:19
I have been looking into Perlin Noise and Simplex Noise..

I understand the concept but it have a hard time to implement it in code..
When reading about Simplex Noise i heard its an upgraded and newer version.. And all resources i find uses the same class.. Should i just copy an enite class or create my own class ?

Here are the resources i found about SimplexNoise:
http://buddat.net/?p=96
http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
https://code.google.com/p/toxiclibs/source/browse/trunk/toxiclibs/src.core/toxi/math/noise/SimplexNoise.java

As i said before, Should i just copy this entire class and implement it into my game or should i spend time to actualy create my own class that generates theese 2d landscapes which is shown in the 1st link.. ?
Feels that im a little bit stupid if i can't create my own Perlin Noise class :/

Suggestions please?
Also in the first link (http://buddat.net/?p=96)
I dont understand what he posted about his own map generation.. I dont understand how i would implement that in my own code and make it draw like he got it to draw..
His code says double tile = SimplexNoise.noise(i / res, j / res); But what would i even use that for ? Tile Placement ?
11  Games Center / WIP games, tools & toy projects / Re: Urban Walker on: 2013-05-04 16:45:07
Im realy impressed with your player animations.. I have alot to learn, But i have never been good at art so i think im just going to beg for someone else to help me Smiley

Great work bro!
12  Game Development / Newbie & Debugging Questions / Re: Key Presses only work randomly on: 2013-05-04 13:24:56

Oh not at all im very sorry, I posted the question also in StackOverflow cause sometimes problems this comunity cannot solve they can. And after i found the solution myself i just posted than on stack overflow and then pasted it here.
Sorry i did not mean to look down on this comunity in any way.

Don't get me wrong, I was kidding Cheesy
Yeah im not Smiley, Just wanted to make sure you did not get me wrong Cheesy
13  Discussions / General Discussions / Re: another Hello thread on: 2013-05-04 13:21:17
Welcome!
14  Game Development / Newbie & Debugging Questions / Re: Key Presses only work randomly on: 2013-05-04 13:19:38

Oh not at all im very sorry, I posted the question also in StackOverflow cause sometimes problems this comunity cannot solve they can. And after i found the solution myself i just posted than on stack overflow and then pasted it here.
Sorry i did not mean to look down on this comunity in any way.
15  Game Development / Game Play & Game Design / Big World vs Random Generated World on: 2013-05-04 13:07:41
Which path would be the best to choose?

Creating a Big world with loads of different spawn would be easier than creating a world that is random generated. But whats the cons of doing that?

Im trying to create like a 2D game that is inspired by MineCraft and i can't stop thinking about how i should solve "creating the world"

If i would create a realy big world with loads of spawns it would in the end serve the same purpose as a random generated world, But it feels like theres a catch to it all..

I was reading about Noise Maps and it seems realy overwhelming but is it worth to learn how to make and use them?

Someone could share their thoughts?
16  Game Development / Newbie & Debugging Questions / Re: Key Presses only work randomly on: 2013-05-03 23:27:35
Solved it by adding frame.revalidate(); in my game loop. Thanks for all answears!
17  Game Development / Newbie & Debugging Questions / Key Presses only work randomly on: 2013-05-03 22:30:00
This is such a strange problem..

Basically i have created a key listener connected to my JPanel.. And sometimes when i compile and run it it does work realy good and no problems what so ever..
But then sometimes when i compile it wont work. It doesn't recognise keypresses.

Here is the code i used for key listener in my JPanels update method:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
        if(keyListener.getMovingRight() == KeyEvent.VK_RIGHT){
            player.playerMoveRight();
        }
        if(keyListener.getMovingLeft() == KeyEvent.VK_LEFT){
            player.playerMoveLeft();
        }
        if(keyListener.getMovingUp() == KeyEvent.VK_UP){
            player.playerMoveUp();
        }
        if(keyListener.getMovingDown() == KeyEvent.VK_DOWN){
           player.playerMoveDown();
        }


And the above code knows if keys was pressed from this class:

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  
public class KeyBoard implements KeyListener {

    private int playerMoveUp;
    private int playerMoveDown;
    private int playerMoveLeft;
    private int playerMoveRight;

    public KeyBoard(){
        playerMoveUp = 0;
        playerMoveDown = 0;
        playerMoveLeft = 0;
        playerMoveRight = 0;
    }

    @Override
    public void keyTyped(KeyEvent keyEvent) {
    }

    @Override
    public void keyPressed(KeyEvent keyEvent) {

        //Switch statement to get which keys were pressed
       switch(keyEvent.getKeyCode()){

            case KeyEvent.VK_UP:
                playerMoveUp = keyEvent.getKeyCode();
                break;

            case KeyEvent.VK_DOWN:
                playerMoveDown = keyEvent.getKeyCode();
                break;

            case KeyEvent.VK_LEFT:
                playerMoveLeft = keyEvent.getKeyCode();
                break;

            case KeyEvent.VK_RIGHT:
                playerMoveRight = keyEvent.getKeyCode();
                break;
        }
    }

    @Override
    public void keyReleased(KeyEvent keyEvent) {

        //Switch statement to get which keys were released
       switch(keyEvent.getKeyCode()){

            case KeyEvent.VK_UP:
                playerMoveUp = 0;
                break;

            case KeyEvent.VK_DOWN:
                playerMoveDown = 0;
                break;

            case KeyEvent.VK_LEFT:
                playerMoveLeft = 0;
                break;

            case KeyEvent.VK_RIGHT:
                playerMoveRight = 0;
                break;
        }
    }

    public int getMovingUp(){
        return playerMoveUp;
    }
    public int getMovingDown(){
        return playerMoveDown;
    }
    public int getMovingLeft(){
        return playerMoveLeft;
    }
    public int getMovingRight(){
        return playerMoveRight;
    }
}


And i ofcourse added the key listener to the JPanel by doing this:
1  
panel.addKeyListener(KeyBoardClasshere);



Since it wasnt working regularly i tried something else called Key Bindigs since i heard that would increase my chances..

I added this in my JPanel class and commented out the key listener in the update method:
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  
    public void keyBindingsInitialize(ActionMap am, InputMap im){
       im.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), "Right");
      am.put("Right", RightBind);
     
      im.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "Left");
      am.put("Left", LeftBind);
     
      im.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "Up");
      am.put("Up", UpBind);
     
      im.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "Down");
      am.put("Down", DownBind);
    }
   
    Action RightBind = new AbstractAction(){
      @Override
      public void actionPerformed(ActionEvent e) {
         // TODO Auto-generated method stub
        player.playerMoveRight();
      }
    };
    Action LeftBind = new AbstractAction(){
      @Override
      public void actionPerformed(ActionEvent e) {
         // TODO Auto-generated method stub
        player.playerMoveLeft();
      }
    };
    Action UpBind = new AbstractAction(){
      @Override
      public void actionPerformed(ActionEvent e) {
         // TODO Auto-generated method stub
        player.playerMoveUp();
      }
    };
    Action DownBind = new AbstractAction(){
      @Override
      public void actionPerformed(ActionEvent e) {
         // TODO Auto-generated method stub
        player.playerMoveDown();
      }
    };


This also works but sometimes when i compile and run the project it just doesnt work and then it works if i terminate the project and then run it again.. Its soo strange in my oppinion.. Anyone have suggestions?
18  Discussions / General Discussions / Re: Your favorite platform games of the last five (5) years? on: 2013-05-03 19:34:17
Braid is my favovite platform game, Its soo well made.
19  Discussions / General Discussions / Re: Hello to all :) on: 2013-05-03 12:34:12
Welcome to the forum, Im also new here Smiley
20  Discussions / Miscellaneous Topics / Re: Class size to make the most of OOP on: 2013-05-02 19:19:32
Quote
Im trying to dicsuss now with you how you see on the subject and im not after a real answear.

Thats what i said. I want your oppinions on the topic. Im not thinking of that classes have to be this or that size...
21  Discussions / Miscellaneous Topics / Class size to make the most of OOP on: 2013-05-02 18:59:01
This might seem like a stupid question, Im trying to dicsuss now with you how you see on the subject and im not after a real answear. What i want is to build my own view on the following subject.

EDIT: For you who didn't know already OOP stands for Object Oriented Programming

When is a java class becoming too big?
How many lines / methods do you try to make per class?
How do you think the above question effecrts your programming?
Do you prefer smaller or bigger classes?
Do you consider OOP be few big classes or many small classes?
Does having many small classes affect you negative?
Does having many big classes affect you negative?

Hoping to start a discussion with spread oppinions Smiley
22  Game Development / Game Play & Game Design / Re: Random Generated 2D world on: 2013-05-02 13:12:00
Great! Big thanks to everyone!!
23  Game Development / Game Play & Game Design / Re: Random Generated 2D world on: 2013-05-02 13:01:21
Oh wow, Sorry i didnt understand that.

So nextInt(100) as an example would give me a number between 0-100 or could it give me negative numbers too?
24  Game Development / Game Play & Game Design / Re: Random Generated 2D world on: 2013-05-02 12:34:36
I mean how to make nextInt(int) only give back a fixed number for example:
I only want a random number between 0-100..
25  Discussions / General Discussions / Re: Blogpost about Java for Game Programming on: 2013-05-02 10:06:47
Intresting read, thank you!
26  Game Development / Game Play & Game Design / Re: Random Generated 2D world on: 2013-05-02 10:04:51
Alright thank you,
I looked through the java.util.random but i dont see any method to get a random int between a certain number..

Lets say i want an int between 0 and 5000.
27  Game Development / Game Play & Game Design / [SOLVED]Random Generated 2D world on: 2013-05-02 09:18:35
I got inspired of the small game "MiniCraft".

How is world randomly generated by code?

Example: I have a world which is the size 2000,2000
How can i make by code that for example trees are randomly placed around on this world?

Im thinking using nested for loops to make it go place on random locations, But also if i manage to for example 10 trees gets randomly placed on the map how do i make not something else spawn where the tree spawns.. Maybe an if statement that checks (array[posx][posy]==0) and then its ok to place for example a rock here?
28  Game Development / Newbie & Debugging Questions / Re: JPanel or Canvas? on: 2013-05-01 15:32:27
How about update methods when it comes to swing components like JFrame and JPanel?
When i run my application just to test the library im making it seems like they are updating themselves autoamtically...
Are they?
29  Games Center / Showcase / Re: Space Turdz on: 2013-05-01 10:16:03
Are you using LWJGL?
If you are: http://www.lwjgl.org/wiki/index.php?title=Distributing_Your_LWJGL_Application
Or you can use jarSplice: http://ninjacave.com/jarsplice
30  Game Development / Newbie & Debugging Questions / JPanel or Canvas? on: 2013-05-01 10:12:09
I have not been programming for too long to know or understand how different java classes is doing when it comes to performance..

This might be a normal question, I did search the forum but didnt find an answear to it.
Which is best to use: JFrame or Canvas?
What are the Pros and Cons with each?

And also something that came to mind right now while typing:
Updating graphics on for example JPanel.. Then you call the paintComponent method.. But that method takes a Graphics g in its parameters.. What is the correct way of calling it from for example a game loop? Should i just create an empty Graphics object on the game initialization and use that or should i actualy declare the object to something?
Pages: [1] 2
 

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

The first screenshot will be displayed as a thumbnail.

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

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

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

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

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

Riven (43 views)
2014-07-14 18:02:53

OpenGLShaders (31 views)
2014-07-14 16:23:47

Riven (30 views)
2014-07-14 11:51:35

quew8 (29 views)
2014-07-13 13:57:52

SHC (65 views)
2014-07-12 17:50:04
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!