Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (546)
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  Game Development / Newbie & Debugging Questions / Re: [Libgdx] setting the stage Ydown on: 2014-04-16 14:25:49
ah yes I have come across this so many times it is becoming annoying, in the current version of Libgdx the Stage class has changed since this.

in the old one what you would do would be

1  
Stage stage = new Stage(Width,Height,true);

where Width and Height would be your screen size

but now stage only takes as a parameter the class Viewport

http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/viewport/Viewport.html

and neither it nor its children classes take the same parameters as the old stage
2  Game Development / Newbie & Debugging Questions / Re: [Libgdx] setting the stage Ydown on: 2014-04-16 02:14:26
I am just using the default Stage using the screenViewport and pass a new orthographic camera with ydown set. the problem I am having is it seems like the bounding box for the buttons and text fields are not matching up.
3  Game Development / Newbie & Debugging Questions / [Libgdx] setting the stage Ydown on: 2014-04-15 18:50:14
I have been working with scene2d.ui stage


this is the stage initialization
1  
2  
3  
4  
5  
6  
OrthographicCamera cam = new OrthographicCamera();
cam.setToOrtho(true);
           
ScreenViewport SV = new ScreenViewport(cam);
         
stage = new Stage(SV);


the reason I have cam.setToOrtho(true);
is because I want the 0,0 to be up in the top left

the text input works if it is given focus at first
but I can not click on it to give it focus


4  Game Development / Newbie & Debugging Questions / Custom Collisions on: 2013-09-17 21:32:07
for the longest time I have been using just rectangles to handle collision, and I was happy with that but I wanted to branch out in to something more complex with polygons using slick2d as the base system.

after some working with it I realized how easy is was compared to what I was doing before, but I ran into a problem.  What I want is the ability to slide up slopes with little to no customization of the engine to handle certain shapes.

this is the basis of what I have so far

Entity.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  
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  
105  
106  
package Pheniox.Entity;

import java.util.ArrayList;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.geom.Shape;
import org.newdawn.slick.geom.Vector2f;
import org.newdawn.slick.state.StateBasedGame;

import Pheniox.World.World;

public abstract class Entity {
   protected Vector2f position = new Vector2f(0,0);
   protected Vector2f velocity = new Vector2f(0,0);
   protected World world;
   public boolean removed = false;
   private Object entities;
   
   //collision booleans
  protected boolean collideTop,collideLeft, collideBottom,collideRight;
   
   //constructors

   public Entity(float x, float y){
      position.x = x;
      position.y = y;
   }
   
   public void init(World world){
      this.world = world;
      init();
   }
   //removes the player from the world
  public void remove(){
      removed = true;
   }
   
   //Movement methods
  public void move(Vector2f vel, int delta){
      move(vel.x, vel.y, delta);
   }
   //takes 2 floats and moves
  public void move(float xa, float ya, int delta){
      if(xa != 0 && ya != 0){
         move(xa, 0,delta);
         move(0,ya,delta);
         return;
      }
     
      boolean canPass = true;
     
      collideTop = false;
      collideLeft = false;
      collideBottom = false;
      collideRight = false;
     
     
      ArrayList<Entity> entities = world.getEntities();
     
      for(Entity e: entities){
         if(e != this){
            if(this.getCollisionBox(xa * delta, ya * delta).intersects(e.getCollisionBox(e.velocity.x * delta,e.velocity.y * delta))){
               canPass = false;
           
         
      }
      if(xa > 0 && !canPass){
         collideLeft = true;
      }
      if(xa < 0 && !canPass){
         collideRight = true;
      }
      if(ya > 0 && !canPass){
         collideBottom = true;
      }
      if(ya < 0 && !canPass){
         collideTop = true;
      }
   }
}
     
     
     
      if(canPass){
      this.position.x += delta * xa;
      this.position.y += delta * ya;
      }
     
   }
   //render methods
  public void render(GameContainer gc, Graphics g){
      renderEntity(gc,g);
   }
   //update methods
  public void update(GameContainer gc, StateBasedGame sbg , int delta){
      move(velocity.x,velocity.y,delta);
      updateEntity(gc,sbg,delta);
   }
   
   //abstract classes
  public abstract void init();
   public abstract void renderEntity(GameContainer gc,Graphics g);
   public abstract void updateEntity(GameContainer gc, StateBasedGame sbg, int delta);
   public abstract Shape getCollisionBox(float xa, float ya);
}


the collision box shape is declared in "getCollisionBox(float xa, float ya)"
when being extends by other classes

basicaly what I want is say in a 2d platformer the ability to go up slopes, and I want it to just inheret to the entity class and not have certain cases that make it happen.

any help would be appreciated.

5  Game Development / Newbie & Debugging Questions / Re: A Strange window bug on: 2013-09-09 15:04:38
Thanks for th help I was thrown for a loop with this one, and I think a lot of people who looked it over felt the same way
6  Game Development / Newbie & Debugging Questions / [Solved]A Strange window bug on: 2013-09-08 23:02:49
I am working on building a game with lwjgl and slick2d as a wrapper for it and I have been experiencing a weird glitch.  the game is a 2d based sidescroller and it applys a naturally gravity to everything in the world,but when I grab the window tab at the top and move it around to reposition the window the player clips through the floor. I have tried to do a updated pausing when the window is not in focus, but the window remains in focus while I am dragging around the window. I know I could fix it by making it a fullscreen game but I would like to have the option available.

Any help would be nice.
7  Game Development / Newbie & Debugging Questions / Re: Entity collision on: 2013-09-04 17:05:47
Thanks everyone I found the problem the collisonManager class was calling the global velocity for the method and wasent spliting them up
8  Game Development / Newbie & Debugging Questions / Re: Entity collision on: 2013-09-04 16:54:17
something I messed up and would like to correct

the move method was ment to be like this

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
   public void move(float xa, float ya, int delta){
    if(xa != 0 && ya != 0){
     move(xa,0, delta);
     move(0,ya,delta);
     return;
    }
   CollisionManager(delta);
      if(canPass){
         pos.x += xa * delta;
         pos.y += ya * delta;
      }
   }

this is what the code was ment to look like but it still errors and dosen't let me slide on walls
9  Game Development / Newbie & Debugging Questions / Re: Entity collision on: 2013-09-04 16:17:19
I am not sure but I am guessing you ment something like

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
 public void CollisionManager(int delta) {
      int x0 = (int)(pos.x + (vel.x * delta));
      int y0 = (int)(pos.y + (vel.y * delta));
      int x1 = (int)(pos.x + width + (vel.x * delta));
      int y1 = (int)(pos.y + height + (vel.y * delta));
     
      List<Entity> entities = world.getEntities(x0, y0, x1, y1);
      for(int i = 0; i < entities.size(); i++){
         Entity e = entities.get(i);
         if(this == e) continue;
            this.touchedBy(e);
           
            if(this.blocksX(e)){
               canPassX = false;
            }
if(this.blocksY(e)){
               canPassY = false;
            }
         }
     
   }


and yeah I like that idea but it conflicts with my intersects method
1  
2  
3  
4  
5  
6  
7  
8  
9  
 // if the player intersects a object with 4 side
  public boolean intersects(int xt0, int yt0, int xt1, int yt1) {
      int xe0 = (int) (pos.x);
      int ye0 = (int) (pos.y);
      int xe1 = (int) (pos.x + width);
      int ye1 = (int) (pos.y + height);
      return !(xe1 < xt0 || ye1 < yt0 || xe0 > xt1 || ye0 >  yt1);

   }


the reason I didn't seprerate this in the first place is becaues I have done tile collision that slides in the past that didn't need to be seperated.
the tile collision I did in the past was simalar to the getEntities(int x0, int y0, int x1, int y1) method in the world class
and I sepeate my move method logic by calling it twice as move(xa,0) and move(0,ya)

so I think it should work but I am guessing there is a mistake somewhere that I didn't notice

what happens is when a entity hits another entity it sticks and I wan't it to be able to slide
10  Game Development / Newbie & Debugging Questions / [Solved]Entity collision on: 2013-09-04 15:20:19
I have been working on a entity system that works fairly well but I have run into a problem that I can't figure out. What I want is for a entity to collide with another entity on lets say the x axis, but can still move freely on the y, entity sliding on another entity. I found little on the subject and what I did find I can't get it to work.

excert of the entity 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  
   public void move(float xa, float ya, int delta){
   CollisionManager(delta);
      if(canPass){
         pos.x += xa * delta;
         pos.y += ya * delta;
      }
   }

   // collision method----------------------------------------------
  // can be overridden to add new collision
  public void CollisionManager(int delta) {
      int x0 = (int)(pos.x + (vel.x * delta));
      int y0 = (int)(pos.y + (vel.y * delta));
      int x1 = (int)(pos.x + width + (vel.x * delta));
      int y1 = (int)(pos.y + height + (vel.y * delta));
     
      List<Entity> entities = world.getEntities(x0, y0, x1, y1);
      for(int i = 0; i < entities.size(); i++){
         Entity e = entities.get(i);
         if(this == e) continue;
            this.touchedBy(e);
           
            if(this.blocks(e)){
               canPass = false;
            }
         }
     
   }

   // if the player intersects a object with 4 side
  public boolean intersects(int xt0, int yt0, int xt1, int yt1) {
      int xe0 = (int) (pos.x);
      int ye0 = (int) (pos.y);
      int xe1 = (int) (pos.x + width);
      int ye1 = (int) (pos.y + height);
      return !(xe1 < xt0 || ye1 < yt0 || xe0 > xt1 || ye0 >  yt1);

   }


and the part of the world class that looks to see if a entity is colliding with another
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
public List<Entity> getEntities(int x0, int y0, int x1, int y1){
      List<Entity> result = new ArrayList<>();
     
      int xt0 = (x0 >> Tile.Tile_Width / 2) - 1;
      int yt0 = (y0 >> Tile.Tile_Height / 2) - 1;
      int xt1 = (x1 >> Tile.Tile_Width / 2) + 1;
      int yt1 = (y1 >> Tile.Tile_Height / 2) + 1;
      for (int y = yt0; y <= yt1; y++) {
         for (int x = xt0; x <= xt1; x++) {
         if(x < 0 || y < 0 || x >= width || y >= height)continue;
         
         for(int i = 0; i < entities.size(); i++){
          Entity e = entities.get(i);
         if(e.intersects(x0,y0,x1,y1)) result.add(e);
         }
      }
     
     
   }
      return result;

   }



thank you
EDIT: the list entities referse to all the entities in the gameworld
11  Game Development / Newbie & Debugging Questions / Re: Instances problem on: 2013-03-05 17:52:24
never mind fixed it I just need to look it see if the tilelist had nulls in it and then just throw those away, my fault , but thanks anyway
12  Game Development / Newbie & Debugging Questions / Re: Instances problem on: 2013-03-05 17:47:19
1  
2  
3  
4  
5  
6  
try{
                     Constructor con = TR.tileClass[i].getConstructor();
                     if(con.newInstance() instanceof Tile){
                         tile = (Tile)con.newInstance();
                     }
                  }catch(Exception e){e.printStackTrace();}


this is the code for what you suggested

 Constructor con = TR.tileClass.getConstructor();

and thats is what is on line 82

but even with the errors it doesn't seem to effect anything so i could do a cheat fix and just remove e.printStackTrace();
13  Game Development / Newbie & Debugging Questions / Re: Instances problem on: 2013-03-05 17:13:35
yeah that was the idea I had in mind but it throws a lot of exceptions.

1  
2  
3  
4  
5  
6  
java.lang.NullPointerException
   at org.TEKGames.World.TiledWorld.LoadWorldFromImage(TiledWorld.java:82)
   at com.test.Game.init(Game.java:21)
   at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:433)
   at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:357)
   at com.test.Game.main(Game.java:40)


It spams that in the console
but for some reason still renders the world

btw I am also using lwjgl and slick2d

and it also says that I need to cast
constructor.newInstance() to tile
14  Game Development / Newbie & Debugging Questions / Instances problem[Solved] on: 2013-03-05 15:51:48
OK, I was working on getting a simple tiled map system up and running to be used as a library, to help make the prototyping process easier.  What I do is I have a register that contains integer array that hold the hexadecimal and a Tile array that just holds the class of the tile.

in the world loading method it take from the data from Tile register and looks for a color that matches. and that brings me to my problem how can I make a new instance of the class that is in the Tile class array; I tried calling newInstance() on it but it just threw an exception and crashed the application.

any help would be appreciated.
15  Game Development / Newbie & Debugging Questions / Re: [Solved]Bullet Logic on: 2012-12-31 19:08:14
Thanks a lot got up and running works like a charm
16  Game Development / Newbie & Debugging Questions / [Solved]Bullet Logic on: 2012-12-31 02:35:11
I looked everywhere for this but couldn't find it. What I wanted to implement into a game is a simple 2d bullet logic that is controlled by the mouse. I understand that you use the slope to determine it but I want to find a guess the ratio between x Velocity and y Velocity to get it to go in the right angle. any help would be greatly appreciated, even if it you are doing it all wrong use this method instead.
17  Game Development / Newbie & Debugging Questions / Slick2d Image problem on: 2012-11-23 23:17:28
I was working on doing some level desing tests and I used the Slick2d getColor(x,y) method. I used it in a for loop that looped through the x and y axis but no matter what it only ever returns the pixel it starts with. I am not sure if this is a bug or what?


 
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
public static Level LoadLevel(String filename) throws SlickException{
       Image map = new Image(filename);
       int w = map.getWidth();
       int h = map.getHeight();
       
       Level level = new Level(w,h);
       Color color;
       for(int y = 0; y < h; y++){
          for(int x = 0; x < w; x++){
              color = map.getColor(x, y);
             System.out.println(x + ", " + y +" Color: " + color);
             Tile tile = new EmptyTile();
             if(color == Color.decode("0x000000")){
                tile = new SolidTile();
             }
             level.SetTile(x, y, tile);
          }
       }
       return level;
   }





Edit: I tried to work it out for a little while longer and it can read the color from the map but when it compairs to the data I have it rejects both of them.
18  Game Development / Newbie & Debugging Questions / Re: Typed Input on: 2012-11-14 16:52:11
I know how to get keyboard input, what I want it to do is record it to a string that can be referenced at a later time.

Edit: I looked at the link you sent and I have tried using that method and it basically spams any key I press, and the method is called key pressed, so i am not sure whats going on.
19  Game Development / Newbie & Debugging Questions / Typed Input on: 2012-11-14 14:57:23
I am using the slick2d API and I wanted to make a input system that its typed. basically if I wanted to name a new game save or character or type in a IP the same way minecraft does, how would I go about doing this with slicks Input system.
20  Game Development / Newbie & Debugging Questions / Re: tile map collision detection on: 2012-10-30 06:28:34
You sort of have the right idea. As for collision I do a comparison between the location of all four sides. Like if the right side of block a is greater than the left side of block and the left side of block a is less than the right side of block b : there will be a collision on the x axis. But that just gives you x and it would collide anywhere on the y axis so you do something very similar to the y a is just with the top and bottom.


Then in the update method have something like if (!solid){x+= xvelocity; y+= yvelocity };  and if x+xvelocity intersects another x of a tile  solid = true so the it dosent update

Hope this helps.
21  Game Development / Newbie & Debugging Questions / Re: SideScroller Problem on: 2012-10-30 06:00:11
I googled it and I love is that was what I needed.  Thanks
22  Games Center / WIP games, tools & toy projects / Re: - Space based first person shooter - Haxel on: 2012-10-28 22:22:59
Looks awesome cant wait to play.
23  Game Development / Newbie & Debugging Questions / SideScroller Problem on: 2012-10-28 22:18:35
I have been working on a sidescroller for about 2 weeks or so. but I was having trouble with I tile that I made to conduct electricity.

how it works is there is a button tile and when you stand on it it trigers the wire and then opens the door. I just use a boolean for each tile to say if its powered or not. Basically my problem the power is doubling back and a wire is powering a wire, not a button.

so How to I have it so that the electricity can go through tons of different* ways but only one at a time.


*By tons I mean 8 one for every tile next to the tile.

Broken Wire Tile Code

http://www.java-gaming.org/?action=pastebin&id=292

all its doing is looking to see if its powered in the update method
and the if(level != null) is important because its tends to load without init'ing the level properly.
24  Game Development / Newbie & Debugging Questions / Re: Image maploading on: 2012-10-28 22:09:39
Ok, Thanks
25  Game Development / Newbie & Debugging Questions / Image maploading on: 2012-10-23 01:06:03
I am not having trouble with the map Loading. my Original one used a .txt doc to find were. But insted I wanted  it make it from a Image, I would prefer if it used the Image class in Slick2d, but I will also settle for a BufferedImage Version.

Thank you in advance for Help.
26  Game Development / Newbie & Debugging Questions / Re: [Update] fixed: Tile Map Design Problem on: 2012-10-22 23:00:06
ok I fixed it, what i needed to so it turn the change the getTile method into getTile(int x ,int y) and the Tile class init's the x and y.

thank you for all the help.

Hopefully the game will be done soon.
27  Game Development / Newbie & Debugging Questions / Re: Tile Map Design Problem on: 2012-10-22 20:24:02
basically to sum it up I want to make a instance of every tile that appears on the screen, because as of now it is making one instance per tile type so the x and y cores for any given tile are the last occurrence of that tile in the map. so what I want to do is every time a tile is set at the start it makes a new version of it.

you responses would be greatly appreciated.
28  Game Development / Newbie & Debugging Questions / Re: Tile Map Design Problem on: 2012-10-22 05:32:09
Just some quic clarifacations the static tile list was there from my old tile referance system. But I am not compleatly sure the new one is good so I left the code laying around. As for the calling it 20 times that occors in the render method when it's getting the tile. The get tile method calls from a 2d array that was loaded from a txt file, basically what I ment was that I have 20 wiretile recorded to the array. And the tile updating inside the entity loop was amistake :p. sorry for all the extra guff in my code I am not the neatest programer.

So from what I gather I need to set the tile Pos. in the set tile method. I am not sure if this is what you mean or maybe you have something better in mind. Thank you for all the help.

WireTile.java

http://www.java-gaming.org/?action=pastebin&id=288

This is basically it when it comes to the wire tile. But I removed the power checking didn't work in the first place.
29  Game Development / Newbie & Debugging Questions / Re: Tile Map Design Problem on: 2012-10-22 03:12:56
Ok ley me try and explain this a little better. The problem I was having is the wiretile in the map is used like 20 time so far but it calls all 20 of them through one class. I want it make copy's of every wiretile so that I can have perminate x and y cords for each tile instead of them swarming through one class per tile. So basically my code to the wire was plans to be something like if(level.getTile(x-1,y).powered) powered = true;  the x and the y would be the tiles position so this would look at the tile to your right to see if it's powered and if it is it would turn on too.

I hope this helps.
30  Game Development / Newbie & Debugging Questions / [Update] fixed: Tile Map Design Problem on: 2012-10-22 02:28:20
I have been working on a Puzzle game,(basically its Like Portal in 2d). the main Ideas is going to be to get a Box on a button so that you can get out the door. But I ran into a design problem with the Tile engine. How its works is it calls entities from an array in the Tile file so as to get there id's and then compairs them to a .txt file to see were they go.

I designed the Door and Button to be Tiles and then I would use another Tile called wireTile. basically it calls every tile of one sort through the same class, so I cant have a perminiate x, or y to any Tile. Do you know anyway to give each tile a more permintate position?

Level.java
http://www.java-gaming.org/?action=pastebin&id=286


Tile.java
http://www.java-gaming.org/?action=pastebin&id=287

here is my Tile and level code.
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.

atombrot (21 views)
2014-08-19 09:29:53

Tekkerue (21 views)
2014-08-16 06:45:27

Tekkerue (21 views)
2014-08-16 06:22:17

Tekkerue (12 views)
2014-08-16 06:20:21

Tekkerue (19 views)
2014-08-16 06:12:11

Rayexar (56 views)
2014-08-11 02:49:23

BurntPizza (37 views)
2014-08-09 21:09:32

BurntPizza (29 views)
2014-08-08 02:01:56

Norakomi (35 views)
2014-08-06 19:49:38

BurntPizza (65 views)
2014-08-03 02:57:17
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!