Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (481)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
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  Game Development / Game Mechanics / Re: LibDGX graphic mechanism on: 2014-07-09 08:04:36
Just use an Orthographic camera and a background that simulates the perspective.
2  Game Development / Newbie & Debugging Questions / Re: Collision Detection with a tiled map (.tmx) on: 2014-06-18 06:17:59
here is a simple loop that would just loop through the entire map. Every step you can check a tile for a "blocked" property, or whatever it is you use to build your collision map:

EDIT: Note that you can remove the mapLayers part of your loop if all your blocking is only happening on one layer. In my old engine I had to potential for blocked objects on multiple layers, so I had to check those as well.
1  
2  
3  
4  
5  
6  
7  
8  
   for (int x = 0; x < mapWidth; x++) {
      for (int y = 0; y < mapHeight; y++) {
         for (int l = 0; l < mapLayers; l++) {
            //x*tileWidth, y*tileHeight == tile the loop is currently on.
           do.stuff(here);
         }
      }
   }


Why you need to check the full map if you know the portion of the map where your sprite is located? This is slow.
3  Game Development / Newbie & Debugging Questions / Re: Teaching Java Game Programming to Children on: 2014-06-17 20:53:42
You can go to Amazon and look at the table of contents of any of the Java for beginners books, for example this. They need to know at least the basics before trying to make any game.
4  Discussions / General Discussions / Re: How to stay focused.. on: 2014-06-17 20:40:41
I use the pomodoro technique with this app: http://www.focusboosterapp.com
5  Game Development / Newbie & Debugging Questions / Re: Collision Detection with a tiled map (.tmx) on: 2014-06-17 20:17:43
You must transform screen coordinates to tile coordinates by dividing the x by the tile width and the y by the tile height.
I think this is the fastest method.
6  Game Development / Newbie & Debugging Questions / Re: No main method can be found on: 2014-06-17 09:19:49
We need to see exactly what you're typing into the command line, as well as the directory structure where you're executing those commands.
  Well, as you want. I have my code here :

C:\Users\Me\Desktop\Project\Code

  And my main class is called Main. So what I type is:
1  
2  
3  
cd Users\Me\Desktop\Project\Code
javac Main.java
java Main


Maybe you has a package defined in Main?

1  
java yourpackage.Main
7  Discussions / Miscellaneous Topics / Re: Longest program you have written? on: 2014-06-17 08:40:34
The longest code I wrote was in my old job, while porting a very old ERP to something "more visual". Around 200K lines or so, with the worst and more obfuscated language that exists in the universe Cranky

And as the longest personal work, there where 2 and I'm not sure which where longer (around 20K lines). One was something like a Windows OS I wrote more than 20 years back in C, and the other a shooter for the Nintendo GameBoy Color.
8  Game Development / Networking & Multiplayer / Re: Patching/Updating games - How would it work? on: 2014-06-12 10:25:30
You can also use Java Web Start to do it automatically for you: http://examples.javacodegeeks.com/java-basics/web-start/java-web-start-getting-started/
9  Games Center / WIP games, tools & toy projects / Re: [libgdx] Project Ultimate - 2D side scrolling platformer on: 2014-06-11 16:10:11
Hi all!
I added a lot of features to the game engine and the game looks much better now. This are some of the most important additions:

-Advanced sprite management. It's able to build sprite animations from a sprite sheet without writing any extra code. You only need to put a new name in an enum and it's ready to use.
-Tile animations
-Tile animation attachments
-Map triggers
-Enemies. Various types with different behaviors.
-Basic global lighting.
-Audio engine.
10  Game Development / Newbie & Debugging Questions / Re: [libGdx]rotating group element cause rectangle misplacement on: 2014-06-11 15:22:37
I know it's not what are you asking but, why don't you use circle collisions instead of rectangles?
11  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Rectangle collision returns different results on: 2014-06-07 19:05:42
The rectangle.overlaps method works fine, it doesn't has much mystery. I think your problem could be that you are moving your sprites or the map at more that 1 pixel per frame, and you don't has this into account.
12  Game Development / Newbie & Debugging Questions / Re: get cell in tiled map on: 2014-06-07 15:52:54
No idea with the library you are using but with libgdx is something like this:
1  
((TiledMapTileLayer)map.getLayers().get(0)).getCell(x,y);
13  Game Development / Newbie & Debugging Questions / Re: libgdx rotation (Sprite, Animation) array issues on: 2014-06-06 08:22:59
but i don't have a bullet angle or Vector2 position???
so now do i have to create them and amend my code?
thanks

You don't need a vector, I put it only as a reference to help you understand how it works.
"vector1.y - vector2.y" is "dy", and "vector1.x - vector2.x" is "dx" in your code.

So, at the end, is something like this:
1  
2  
3  
4  
5  
6  
7  
float targetX = GameWorld.getBall().getX();
float targetY = GameWorld.getBall().getY();
float dx = targetX - getX();
float dy = targetY - getY();
float angle=MathUtils.toDegrees(MathUtils.atan2(dy,dx)); // <-----
...
setRotation(angle);


I suggest you to learn Java better before attempting to make a game like this. You are a bit lost in basic things.
14  Game Development / Newbie & Debugging Questions / Re: libgdx rotation (Sprite, Animation) array issues on: 2014-06-05 09:16:07
As English is not my main language I'm not sure if is this what you are asking, but to get the rotation angle to point to other vector you can use
1  
double angle=MathUtils.atan2(vector1.y - vector2.y, vector1.x - vector2.x)

The angle is returned in radians, if you need it in degrees, MathUtils has a method to transform it.

For the other question about having multiple bullets, enemies,... , use the Pool class in libgdx.
15  Discussions / Miscellaneous Topics / Re: Random syntax tweaks! on: 2014-06-04 11:12:25
I love the princec idea but applied to constructors to have a destructor

1  
2  
3  
4  
5  
public foo() {
...
} finally {
    yourDisposableObject.dispose();
}


It will be nice to have a short object construction syntax when left & right is the same. Instead of
1  
YourClassObject<Class1,Class2> var= new YourClassObject<Class1,Class2>(params);

have this
1  
YourClassObject<Class1,Class2> var= new(params);


And to have by reference parameters instead of only by value
1  
2  
3  
4  
5  
void swap(int a, int b){
int c=a; a=b; b=c;
}

swap(&a,&b);

16  Game Development / Performance Tuning / Re: Cache locality and LibStruct - fixing Java's horrible memory layout on: 2014-05-19 08:32:35
Why you need to compute 100 000 entities if it's impossible to have all of them on screen? Compute only what is on screen and you will get 60 fps easily.
17  Game Development / Newbie & Debugging Questions / Re: [LIBgdx] Unable to get LibGdx installed & running with new installer on: 2014-05-04 18:23:54
You must install the gradle plugin into Eclipse (Help -> Install New Software... & put the URL). The gradle url is: http://dist.springsource.com/release/TOOLS/gradle
18  Discussions / General Discussions / Re: Must have Software for Game Creation on: 2014-05-04 13:22:20
For pixel art you must include Cosmigo Pro Motion  Smiley
19  Game Development / Newbie & Debugging Questions / Re: [Libgdx] how to use GLES20 on: 2014-04-30 09:09:48
Okey I'm starting to get annoyed by this..

1  
2  
3  
4  
      Gdx2DPixmap pixmap;
      System.out.println(pixmap.getPixel(0, 0));
      pixmap.setPixel(0, 0, 0);
      System.out.println(pixmap.getPixel(0, 0));


I finally come to write this code. The problem is that here is what it prints out.

1915447807
1915447807

I basically load the pixmap somewhere in the code and value at 0,0 happens to be 1915447807. The problem is that it doesn't change after I do setPixel(0, 0, 0). In second print statement, it should be 0, but it didn't change. Do I need to call some kind of method like pixmap.flush or pixmap.update for it to change?


I'm not sure but try if with setPixel(0, 0, Color.rgba8888(0,0,0,1)); works.
20  Game Development / Newbie & Debugging Questions / Re: ConcurrentModificationException when removing an item from an arraylist on: 2014-04-28 11:31:34
If the order is not important, you can write your own list class that avoids all the overloads. Every time an element is deleted, you can overwrite the deleted item with the last item in the list, then decrease the list size counter. That way you can remove items without speed penalty and you don't need two lists, and all the copies that can be worse than the deletes. I have use this in my Retroships game and it works like a charm.

Loved your tip, Endos. I wish I'd known about that technique before! Although I didn't need to write my own List class at all.
A regular ArrayList is capable to pull that out. Check it out:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
static final int BULLETS = 100;
final List<Bullet> bullets = new ArrayList<>(BULLETS);

public void displaySpritesRegular() {
  stroke(Bullet.COLOUR);
  for (int b = bullets.size(); b-- != 0;)
    if (bullets.get(b).script()) {
      bullets.remove(b);
      System.out.println("A bullet has strayed too far from view!");
    }
}

public void displaySpritesOptimized() {
  stroke(Bullet.COLOUR);
  for (int b = bullets.size(), len = b; b-- != 0;)
    if (bullets.get(b).script()) {
      final Bullet u = bullets.remove(--len);
      if (b != len)  bullets.set(b, u);
      System.out.println("A bullet has strayed too far from view!");
    }
}


Yes, this will work, but as the source code is available, IMO, is better to write your own class based on that source and just call remove without any check and additional work.

And for your concrete example, you could make a variation, as for sure if you remove any bullet, you will need to add new bullets again. Instead of overwriting the removed item with the last one, you can exchange both values. That way you can have in one list an "in use" and "unused" list of bullets. When you needs a new bullet, the only thing you needs is increase the size counter and return the last element to reuse it, if there is one of course.
21  Game Development / Newbie & Debugging Questions / Re: ConcurrentModificationException when removing an item from an arraylist on: 2014-04-27 19:19:25
If the order is not important, you can write your own list class that avoids all the overloads. Every time an element is deleted, you can overwrite the deleted item with the last item in the list, then decrease the list size counter. That way you can remove items without speed penalty and you don't need two lists, and all the copies that can be worse than the deletes. I have use this in my Retroships game and it works like a charm.
22  Discussions / General Discussions / Re: The Differences between Java and JavaScript. on: 2014-04-27 18:51:28
There are a lot of differences between both, but the most notable difference IMO is that Java is strongly typed while Javascript is not.
It's a nightmare to make big programs with a weak typed language.
23  Game Development / Newbie & Debugging Questions / Re: ConcurrentModificationException when removing an item from an arraylist on: 2014-04-26 09:55:38
There is one synchronized list: Collections.synchronizedList()

1  
2  
3  
4  
5  
6  
7  
 List list = Collections.synchronizedList(new ArrayList());
      ...
  synchronized (list) {
      Iterator i = list.iterator(); // Must be in synchronized block
     while (i.hasNext())
          foo(i.next());
  }


24  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java Slick2D: When camera is scrolling, character moves too fast on: 2014-04-23 17:50:34
The problem is that you are moving both, the player and the camera, at the same time.
If the camera moves, the player must stop, and vice versa. Instead of using the player coordinates, use other variables and update the player or the camera depending on what must move.
25  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Forground and background camera pan on: 2014-04-23 12:00:36
I think you are talking about parallax scrolling. Is something like this?
If yes, you can do it by using one camera per layer.
26  Game Development / Newbie & Debugging Questions / Re: LibGDX Errors in New Project on: 2014-04-14 19:35:42
OpenGL ES 1.x support has been removed recently from libGDX. Replace any GL10 sentence in the code for GL20.
Also if you has a line similar to cfg.useGL20=false;, remove it.

The constructor error is because you are passing the Main from the desktop version (yourproject-desktop) instead of the Main of the main class (yourproject).
27  Discussions / General Discussions / Re: Rendering a 2.5D game on: 2014-04-14 18:50:01
I think you are looking for something similar to the mode 7
28  Discussions / Miscellaneous Topics / Re: What are Anti-Virus Developers Protecting us From? on: 2014-04-14 09:48:34
Anti-virus are a waste of resources, I never used one while I was using Windows (from Windows 3.0 to XP), and I never used one now that I use a Mac.
What worked for me for years with Windows was the use a good firewall and a restricted user account for working, and never use the admin account directly but with the execute as option when needed.
29  Game Development / Newbie & Debugging Questions / Re: LibGDX Mouse Position While Zoomed in on: 2014-04-10 15:05:58
I have not try it, but I think that camera.unproject() should work as well.
30  Game Development / Newbie & Debugging Questions / Re: Opening an inventory Screen on: 2014-04-10 15:00:29
Your if is wrong, just see the =

1  
if(Inventory.inventoryOpen=false)


instead of the ==

1  
if(Inventory.inventoryOpen==false)
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.

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

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

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

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

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

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

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

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

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

BurntPizza (67 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!