Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
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 / Newbie & Debugging Questions / Re: Using ArrayList<> adding and removing objects on: 2013-10-21 23:01:28
as i said erlier, removing from a list you are looping through will break it.

e.g.

at item 5 of 10.

item 5 gets removed. there are no longer 10 items, loop get confused and breaks.
That is why you should use the 'hasNext()' loop i mentioned before or LinkedList way.

I had a look, blackberry does not have arraylists like you said it has its own version(s), you can write your own arraylist but I think blackberry wants you to use something like their 'Vector' class. see here: http://stackoverflow.com/questions/1428891/blackberry-jde-arraylist/1429744#1429744
2  Game Development / Newbie & Debugging Questions / Re: Using ArrayList<> adding and removing objects on: 2013-10-21 22:39:49
Very odd. I have not worked with the blackberry JDT so cannot really comment.

<> is the object type. You can ignore this and get away with some clever tricks (as mentioned by a previous user)

but it just means that if your Array (or ArrayList) if going to hold a bunch of strings, you are telling it in advance. Just tell it the class. in this case, your array holds many PlayerRocket(s) so 'new ArrayList<PlayerRocket>'

out of interest, can you do the following without it complaining:

1  
java.util.ArrayList<String> test = new java.util.ArrayList<String>();

3  Game Development / Newbie & Debugging Questions / Re: Is It Okay To Static-ify Random? on: 2013-10-21 22:35:38
I am getting into static code more and more, (never used it 6 months ago).

Most 'utility' code in my new game is static and I have found it VERY useful to do so. such as my method for getting 'real' mouse position (camer.unproject() etc from libgdx).

I am picking up the importance of static code and instantly seeing the benefits.
4  Game Development / Newbie & Debugging Questions / Re: Using ArrayList<> adding and removing objects on: 2013-10-21 22:32:11
.....ArrayList<> is bog standard java...
5  Game Development / Newbie & Debugging Questions / Re: Using ArrayList<> adding and removing objects on: 2013-10-21 22:31:16
It sounds like pretty standard bullet removal. My standard approact is as follows (not in code, just example)

on each render(re paint)

loop through bullets (as in previous post)
check if the bullet can be remove (I useally give bullets a 'life time' and when they hit zero (and have not hit anything) remove them).
if it needs removing, remove it (as shown in previous post).
repeat.

Unless there are thousands of bullets (rockets in this case) or they need a lot of logic ran against them or the game is running on an old/slow device, just do this in the render loop.

if it does effect your FPS, just create a thread for this.

If this is of use and you would like me to put it into code just say.
6  Game Development / Newbie & Debugging Questions / Re: Is It Okay To Static-ify Random? on: 2013-10-21 22:21:23
What i mean by static println is: I read through someones github code a few days ago and there was a static method called println(String input), that just shortened 'System.out.println'. Its pretty pointless, much like a static Random(). Just create one, use it as much as possible and where not possible create another. Again, I am sure this is bad practice but it works for me.
7  Game Development / Newbie & Debugging Questions / Re: Libgdx - Use Tiled or http://tide.codeplex.com/ ? on: 2013-10-21 22:19:06
Of corse you could so that with most things, but it is nice to work with native tools.
8  Discussions / General Discussions / Re: Java-Gaming at Minecon on: 2013-10-21 22:17:47
I beleive Java2D is the best place to start but it is just a starting point, game development has become a fight for platform support. It has become 'bad practice' to write a game that works on one platform. libs like libGDX are fantastic for providing that multi-platform support but they can feel like jumping into the deep end of programming.

I personally feel giving the guests a teardown of Catacomb Snatch, explaining how came together on a basic level would be good. As little 'here is what you type' as possible, the guests can take it from there if they want to continue down the development path.
9  Game Development / Newbie & Debugging Questions / Re: Libgdx - Use Tiled or http://tide.codeplex.com/ ? on: 2013-10-21 22:12:16
Having played with both I have found tide support in libGDX to lack some features and the tide editor. Unless I am mistaken, tide editor only seems to run on windows.
10  Game Development / Newbie & Debugging Questions / Re: Is It Okay To Static-ify Random? on: 2013-10-21 22:06:06
oh, totally agreed. btw, isnt having a static random almost as bad as having a static method for println?
11  Game Development / Newbie & Debugging Questions / Re: Is It Okay To Static-ify Random? on: 2013-10-21 21:56:31
It can be used in a static method... Thats all the static I ever need Wink
12  Game Development / Newbie & Debugging Questions / Re: Is It Okay To Static-ify Random? on: 2013-10-21 21:52:34
I use
1  
int myRand = new random().nextInt();


if it HAS to be static-ish

(although I am sure many of you are cringing reading this)
13  Game Development / Newbie & Debugging Questions / Re: Using ArrayList<> adding and removing objects on: 2013-10-21 21:45:36
is this what you want?:


1  
2  
3  
4  
5  
6  
7  
ArrayList<PlayerRocket> playerRocketsArray = new ArrayList<>(PlayerRocket);

for(PlayerRocket pr: playerRocketsArray){
   if(wantToRemoveRocket){
      playerRocketsArray.remove(pr);
   }
}


although this can cause issues (bad to remove items from a list you are looping through)

so this may be better for you:

1  
2  
3  
4  
5  
ArrayList<PlayerRocket> playerRocketsArray = new ArrayList<>(PlayerRocket);
for (Iterator i = playerRocketsArray.listIterator(); i.hasNext();) {
   PlayerRocket pr = (PlayerRocket) i.next();
   if (wantToRemoveRocket) i.remove();
}
14  Game Development / Newbie & Debugging Questions / Re: Isometric issues on: 2013-10-20 21:54:34
I have to rewrite it a little (due to float positions and Vector2 over Point). Could you please clarify what: isoPoint, viewportOrigin and isoDims are please. Thank you
15  Game Development / Newbie & Debugging Questions / Re: Isometric issues on: 2013-10-20 21:23:32
Thank you for your fantastic reply. I have spent hours trying to figure this out. (Math is not my strong point). Thanks again.
16  Game Development / Newbie & Debugging Questions / Re: Isometric issues on: 2013-10-20 20:37:38
Anybody?
17  Game Development / Newbie & Debugging Questions / Isometric issues on: 2013-10-19 00:31:59
I have a little project, I am rendering paths over an isometric map using:


1  
2  
3  
4  
5  
6  
7  
8  
      xOffset = GameMap.tileWidth * GameMap.unitScale;
      yOffset = GameMap.tileHeight * GameMap.unitScale;

public static Vector2 orthToIso(float x, float y) {
      float drawingPosX = x * xOffset / 2 + y * xOffset / 2;
      float drawingPosY = y * yOffset / 2 - x * yOffset / 2;
      return new Vector2(drawingPosX, drawingPosY);
   }


This works great, the issue I have is being able to have a path go to the tile the mouse/touch is over

the mouse/touch position is going to be translated to iso via the above as part of the render loop. What I need help with is offseting the above code so that when the orth->iso kicks in, it lines up...

I hope this makes sense Smiley
18  Game Development / Newbie & Debugging Questions / Re: Getting the sinking feeling on: 2012-07-11 00:00:57
Thank you,

I made the changes you suggested and it is working fine.

private void gravity() {

      float Y = sprite.getY();

      speed += accel * Gdx.graphics.getDeltaTime();

      if (sprite.getY() <= floor && speed < 0) {
         grounded = true;
         speed = 0;
         sprite.setY(floor);
      }
      Y += speed * Gdx.graphics.getDeltaTime();
      sprite.setY(Y);
   }
19  Game Development / Newbie & Debugging Questions / Getting the sinking feeling on: 2012-07-10 23:42:18
I am implementing basic gravity+floor collision but due to the speed always increasing, after I hit the floor I sink like im stood in quicksand, the issue is that if I put an 'if !grounded around the gravity calculations jumping will not work.

Any ideas?

private void gravity() {
      
      float Y = sprite.getY();

      speed += accel * Gdx.graphics.getDeltaTime();
      Y += speed * Gdx.graphics.getDeltaTime();
      sprite.setY(Y);

      if (sprite.getY() <= floor) {
         grounded = true;
         speed = 0;
      }
   }


public void controls() {
      if (Gdx.input.isKeyPressed(Keys.W) && grounded) {
         grounded = false;
         speed = 300;
      }
}
20  Game Development / Game Mechanics / Re: npc move to X,Y smooth on: 2012-05-16 18:20:43
Cheesy Thanks

I was having a look at this: http://www.aurelienribon.com/blog/projects/universal-tween-engine/

Its looks to be what I am looking for, will have a play when I get home.
21  Game Development / Game Mechanics / Re: npc move to X,Y smooth on: 2012-05-16 18:15:01
My original idea was to have each npc take its current position and it target position and create a spline path to follow, I am researching it now but didnt know if you guys had any better ideas?
22  Game Development / Game Mechanics / npc move to X,Y smooth on: 2012-05-16 18:00:10
Good afternoon,

I am working on a A.O.E style game and am currently implementing the target positions for villagers,
I do not need to do any A* pathfinding due to there being no obstacles but I also dont want to do some ugly: if (x < x2) x++; style movement as its ugly when the npc reaches its destination on one axis and then just walks strate, is there any nice, smooth technique for me to give an npc a destination for it to move and have it follow a soft like to its destination.

Martin
23  Game Development / Game Play & Game Design / Re: Proof of concept video. Slick2D tank game on: 2012-04-29 23:06:22
That's pretty cool. How are you handling the angle of fire (trajectory)?
24  Game Development / Newbie & Debugging Questions / Re: Masking in libGDX on: 2012-04-23 13:20:38
Thanks tom, That worked exactly as I needed it to.

25  Game Development / Newbie & Debugging Questions / Re: Masking in libGDX on: 2012-04-23 10:35:27
I had to change my approach due to LD48 time constraints and my lack of knowlage on the subject.

But what I wanted was to have an image of some stars, ontop of that an image of terrain and ontop of that an circular image to crop the terrain to a circle and allow me to see the image of the stars underneath.
26  Java Game APIs & Engines / Engines, Libraries and Tools / Basic Sphere with texture in libGDX on: 2012-04-21 22:48:41
How can I go about making a basic sphere in libgdx with a texture applied. I do not want lighting.

If i use a lwjgl SPHERE I am unable to see it and do not see how to texture it.

Sphere s = new Sphere();

s.draw(16f, 5, 5);
27  Game Development / Newbie & Debugging Questions / Re: Masking in libGDX on: 2012-04-21 20:49:29
Is there a better way to subtract one image from another in libGDX?
28  Game Development / Newbie & Debugging Questions / Re: Masking in libGDX on: 2012-04-21 20:33:03
I cannot seam to figure out any combination that works Sad Its not a good day.
29  Game Development / Newbie & Debugging Questions / Masking in libGDX on: 2012-04-21 19:57:57
Hey chaps,

I cant seam to find the equivalent of this(http://slick.javaunlimited.net/viewtopic.php?p=19140) in libGDX.

I have 3 images: stars, the a circle shape and some terrain.

I am trying to just display the terrain inside the circle so that the stars texture can be moved to give a fake pan/tilt effect.

I have been trying via the following but suspect it is the wrong technique:

      batch.begin();
      batch.draw(stars,0,0,WIDTH,HEIGHT);
      batch.draw(terrain,0,0,WIDTH,HEIGHT);
      Gdx.gl.glColorMask(false, false, true, true);
      batch.draw(mask,0,0);
      Gdx.gl.glColorMask(true, true, true, true);
      batch.end();
30  Java Game APIs & Engines / OpenGL Development / Re: Holding down keys on: 2012-04-17 12:35:33
I only just noticed these posts, sorry. Thanks for the info guys, I will implement this tonight. You are a great community.
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.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (24 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

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

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

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

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

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

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
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!