Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (408)
games submitted by our members
Games in WIP (293)
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 / Enemy Shooting Question on: 2013-05-24 21:53:07
Hey Everyone,

My question is how would you go about making an enemy shoot like the ones in the famous Japanese game "TouHou" by Zun. Does anyone know how this would be possible. ?
I would like the enemy to shoot in all directions. i know how to get the angle of a bullet but how would i shoot multiple bullets from all angles ?

Thanks.
2  Game Development / Newbie & Debugging Questions / Checking for characters in a .txt file. instead of numbers ? [need help] on: 2013-05-10 21:28:54
Hey everyone,

I have a question. Basically I know how to read a .txt file for numbers and i know how to add a lets say a block in the position of a '1' and nothing in the position of '0' EXAMPLE BELOW.
1 1 1 1 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 1 1 1 1

My problem is, i don't really want to read numbers all the time. i want to be able to make maps using symbols such as '#'.EXAMPLE BELOW
# # # #  #
# 0 0 0 0 #
# 0 0 0 0 #
# # # # #

Does anyone know how to do this ?

Thanks
3  Game Development / Newbie & Debugging Questions / Re: Rotating bullet bullet shot[Solved] on: 2013-05-05 16:51:51
Ok guys i figured it out. Thanks for the help though. if you are wondering how i did it. this is how :


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
//Constructor of my bullet class. with the angle, x position and y position
public Bullet(double angle,int x, int y){
      this.x = x;
      this.y = y;
     
             // this is what makes the bullet move towards the mouse cursor. and getX() and getY() are the positions of the bullet.
     rad = Math.atan2(getY() - Game.mouseY, getX() - Game.mouseX) - Math.PI;
             // this is how i change the angles
     dx = Math.cos(rad) * speed;
      dy = Math.sin(rad) * speed;
}


When i shoot the bullet i the angle is the "rad" variable. I hope this helps.
-GlennBrann
4  Game Development / Newbie & Debugging Questions / Re: Rotating bullet bullet shot[need help] on: 2013-05-05 01:45:32
Yeah thats what i want to do.
5  Game Development / Newbie & Debugging Questions / Rotating bullet bullet shot[Solved] on: 2013-05-05 01:12:03
Hey Everyone,

So i'm having this problem that i can't seem to figure out and i can't find it on here. Maybe i'm just wording it wrong. basically what i want to do is where ever i press my mouse on the game i want a bullet from the player to shoot towards where ever i press. So my game is a top down game and i just can't seem to figure it out. I know how to rotate the bullet manually but i don't know how to do it with the mouse. I appreciate any help. thank you.
6  Game Development / Newbie & Debugging Questions / Re: Player wall collision sliding problem [Need Help] on: 2013-05-04 00:31:52
Yeah, id love some help please. every little helps. Thanks Smiley
7  Game Development / Newbie & Debugging Questions / Re: Player wall collision sliding problem [Need Help] on: 2013-05-03 20:17:03
Yes i have read your post i meant to say thank you. Ill need to try that out i just didn't see it in time. Sorry about that. ill try it now Smiley
-GLenn
8  Game Development / Newbie & Debugging Questions / Re: Player wall collision sliding problem [Need Help] on: 2013-05-03 19:02:15
also, could you maybe show me the best way in which to move the player. what should i change ?
9  Game Development / Newbie & Debugging Questions / Re: Player wall collision sliding problem [Need Help] on: 2013-05-03 18:48:45
Hey sorry for not being clear enough. Basically if i try to slid along a wall i just stop moving. i cant slide. here is my collision code :
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
   public void collision(double x, double y) {
      int leftTile = tileMap.getColTile((int) (x - width / 2));
      int rightTile = tileMap.getColTile((int) (x + width / 2) - 1);
      int topTile = tileMap.getRowTile((int) (y - height / 2));
      int bottomTile = tileMap.getRowTile((int) (y + height / 2) - 1);
      topLeft = tileMap.getTile(topTile, leftTile) == 1;
      topRight = tileMap.getTile(topTile, rightTile) == 1;
      bottomLeft = tileMap.getTile(bottomTile, leftTile) == 1;
      bottomRight = tileMap.getTile(bottomTile, rightTile) == 1;
     
   }
10  Game Development / Newbie & Debugging Questions / Player wall collision sliding problem [Need Help] on: 2013-05-03 00:13:16
Hey Everyone,

I'm having problems with my collisions. Basically when i colliding against a wall i cant slide if i press another key..For example. if i press The left arrow key and i am on the wall, if i continue to hold this key and try to press the up arrow my player wont move upwards. I hope you know what i mean. I know its probably a really easy fix but i need help.

Here is my player 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  
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  
   public void update() {

      movePlayer();
      // Check Collision;

      int curCol = tileMap.getColTile((int) x);
      int curRow = tileMap.getRowTile((int) y);

      double xDest = x += dx;
      double yDest = y += dy;

      double tempX = x;
      double tempY = y;

      collision(x, yDest);
      if (dy < 0) {
         if (topLeft || topRight) {
            dy = 0;
            tempY = curRow * tileMap.getTileSize() + height / 2;
         } else {
            tempY += dy;
         }
      }
      if (dy > 0) {
         if (bottomLeft || bottomRight) {
            dy = 0;
            tempY = (curRow + 1) * tileMap.getTileSize() - height / 2;
         } else {
            tempY += dy;
         }
      }
      dy = 0;
      collision(xDest, y);
      if (dx < 0) {
         if (topLeft || bottomLeft) {
            dx = 0;
            tempX = curCol * tileMap.getTileSize() + width / 2;
         } else {
            tempX += dx;
         }
      }
      if (dx > 0) {
         if (topRight || bottomRight) {
            dx = 0;
            tempX = (curCol + 1) * tileMap.getTileSize() - width / 2;
         } else {
            tempX += dx;
         }
      }
      dx = 0;

      x = tempX;
      y = tempY;

      tileMap.setX((int) (Game.WIDTH * Game.SCALE / 2 - x));
      tileMap.setY((int) (Game.HEIGHT * Game.SCALE / 2 - y));
   }

   public void movePlayer() {
      if (left) {
         dx -= moveSpeed;
      }
      if (right) {
         dx += moveSpeed;
      }
      if (up) {
         dy -= moveSpeed;
      }
      if (down) {
         dy += moveSpeed;
      }
   }


I might have an idea on how to do it. i think you could use something like

1  
2  
3  
if(dx != 0 && dy != 0){
//Something in here
           }


Please any help is much appreciated.
Thanks
- GlennBrann
11  Games Center / Showcase / Re: Space Turdz on: 2013-05-01 16:38:16
Hey sorry about that. hopfully its working now. it works fine on my computer. I updated the link
12  Games Center / Showcase / Re: Space Turdz on: 2013-05-01 16:38:03
Hey sorry about that. hopfully its working now. it works fine on my computer. I updated the link
13  Games Center / Showcase / Space Turdz on: 2013-04-30 20:21:57
Hey Everyone,
I just wanted to showcase a game i have been working on and off for the past while.
you can download the game here: http://www.mediafire.com/?t6c81t78b3b5d4a





Tell me what you think. All feedback accepted.

Thanks
-GlennBrann
14  Game Development / Newbie & Debugging Questions / Corner collision detection. [Need Help] on: 2013-04-26 20:19:50
Hey Everyone,

I know some of you are thinking i hate these posts. but i just can't find any good posts teaching how to do corner Collision. Basically I'm taking part in Ludum dare tonight and i know basic enough collision but i want to hopefully make a plat former of the sort. but the problem is. I dont know how to go about doing proper collision. when i move my player against a certain tile i want the player to stop moving. How would i implement this in a some what simple form. I'm using no libraries. IF ANYONE can just give me some code to represent my idea could you please help. I'm having alot of trouble.

I try to stop the players velocity when it interects with a tile but the player keeps jumping slowly through the tile. I am trying to move away from .intersects(). Could you please help Thanks

- GlennBrann
15  Game Development / Newbie & Debugging Questions / Re: Re-Spawning in same position with same enemy states [Help Needed] on: 2013-04-26 19:14:11
Thank you. That's what i needed Smiley
16  Game Development / Newbie & Debugging Questions / Re: Re-Spawning in same position with same enemy states [Help Needed] on: 2013-04-25 19:13:11
But the problem is, the enemies randomly spawn every level.
17  Game Development / Newbie & Debugging Questions / Re-Spawning in same position with same enemy states [Help Needed] on: 2013-04-25 19:07:08
Hey Everyone,

I have a question. I tried to add a lives system to my game where you have 2 lives and after you die you can re-spawn. and when you reach 0 lives you have to re-start. The problem that i am having is when i hit re-spawn, i can't seem to figure out an efficient way of re-spawning enemies in the same position as they were when i died. and the same with the player. do you have any ideas on how to do this.

One theory i thought of was i could have the enemies & update method pause when i die and just have the re-spawn menu overlay the screen and when i hit respawn i plays the game again, what do you think. ?

Please help thanks Smiley
18  Game Development / Newbie & Debugging Questions / Re: Need help with displaying text for a certain amount of time [UnSolved] on: 2013-03-30 03:47:23
just the regular java library. no 3rd party libraries.
19  Game Development / Newbie & Debugging Questions / Need help with displaying text for a certain amount of time [UnSolved] on: 2013-03-30 03:07:15
Hello Everyone,

I need your help on something and i would really appreciate it. I just cant get my head around doing it. Basically what I want is,when I change level in my game I want to text on the screen saying "Next Level" for about 2 seconds, then disappear. This might seem really basic but i just want to know whats the best way to do this.

Does anyone know how ?

Thanks for you help,
- GlennBrann
20  Games Center / WIP games, tools & toy projects / Re: Space Turdz on: 2013-03-27 21:47:32
Thanks for the feed back.  Grin
21  Games Center / WIP games, tools & toy projects / Space Turdz on: 2013-03-27 21:27:38
Hello Everyone,

I decided back in January that I wanted to make a game. I couldn't think of any good ideas so I decided to create a weird and fun game called Space Turdz. It has been on and off development for the past 3 months but  I am making good progress on it over the last few weeks.

The game is based off the old Space Invaders game but it has a twist. You start off by falling from outer space to try fend off aliens. and other enemies in the future. The aliens "PooPoo" on you for a lack of a better word.(haha). You have a gun that shoots toilet paper at the aliens and they die. At the moment the game only has one level. In each level there will be multiple waves of enemies of different kinds. I plan on having a boss fight at the end of every second level. Also a new Zone/Area.

There is a few pick ups at the moment such as extra ammo and extra health, but i plan on adding better and more fun pick ups in the future.
I don't have a main plot/story line but I really want to add one, but its going to be kinda hard. but ill see what I can do.

Here is an image of what the first level looks like. I will be giving it up for download in the near future for people to play.

28th of March 2013.


Please tell me what you think.

P.S (All art was made by myself and music was made by a friend).

Thanks
- GlennBrann
22  Game Development / Newbie & Debugging Questions / Jumpy Movement [need help] on: 2013-02-24 15:04:15
Hello Everyone, Recently i have been having trouble with smooth movement. i have tried multiple ways but i continuesly get jumpy movement. i'm not sure if it has something to do with my game loop or is it something to do with how i move my player. Down below is my gameLoop how i move my player and my Input class. i would love some help thanks alot Smiley

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  
public void run() {
      long lastTime = System.nanoTime();
      double nsPerTick = 1000000000.0 / 60.0;

      int ticks = 0;
      int frames = 0;

      long lastTimer = System.currentTimeMillis();
      double delta = 0;

      init();

      while (running) {
         long now = System.nanoTime();
         delta += (now - lastTime) / nsPerTick;
         lastTime = now;
         while (delta >= 1) {
            ticks++;
            tick();
            delta--;
         }

         try {
            Thread.sleep(16);
         } catch (InterruptedException e) {
            e.printStackTrace();
         }

         frames++;
         render();

         if (System.currentTimeMillis() - lastTimer >= 1000) {
            lastTimer += 1000;

            System.out.println("FPS " + frames + " TICKS " + ticks);

            ticks = 0;
            frames = 0;
         }
      }
   }


Player Movement:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
public void tick(ArrayList<grassBlock> grass){
      x += velX;
      y += fallSpeed;
     
      if(Falling){
         fallSpeed += Gravity;
      }
     
      if(fallSpeed == 5){
         fallSpeed = 5;
      }
   }


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

   public Game game;

   public Input(Game game) {
      this.game = game;
   }

   public void keyPressed(KeyEvent e) {
      int key = e.getKeyCode();
      if (key == KeyEvent.VK_A) {
         game.getPlayer().setVelX(-4);
      }else if (key == KeyEvent.VK_D) {
         game.getPlayer().setVelX(4);
      }
   }

   public void keyReleased(KeyEvent e) {
      int key = e.getKeyCode();
      if (key == KeyEvent.VK_A) {
         game.getPlayer().setVelX(0);
      }else if (key == KeyEvent.VK_D) {
         game.getPlayer().setVelX(0);
      }
   }

   public void keyTyped(KeyEvent e) {
   }

}


Thanks for help
23  Discussions / General Discussions / How would you go about designing levels from set colours from a .png file ? on: 2013-02-18 22:07:42
Hello, I don't know wheather my title was clear enough but i was wondering. How would i go about setting certain colours such as "0xff00ff" to lets say a grass block. and when ever there is that colour "0xff00ff" on a .png file it places it in the world. Is this complicated to. PS i am making a 2D game so its not a 3d game. Also another example would be this would be from Notch's Metagun game from the ludum dare competition:

I hope you can help thanks.

- GlennBrann
24  Game Development / Newbie & Debugging Questions / Re: Null Pointer Exception when enemy tries to shoot "NEED HELP" on: 2013-02-03 23:26:17
what files would i need to give you to get more help ?
25  Game Development / Newbie & Debugging Questions / Cant place "rock" at enemies position. (Getting NullPointerException) FIXED on: 2013-02-03 23:21:18
Could someone delete this post. Thanks
26  Game Development / Newbie & Debugging Questions / Re: IndexOutOfBounds index: 7 size: 7 [SOLVED] on: 2013-02-03 22:55:20
Haha, Thanks for explaining it. really helped Smiley
27  Game Development / Newbie & Debugging Questions / Re: IndexOutOfBounds index: 7 size: 7 [SOLVED] on: 2013-02-03 22:48:44
no your one worked. Thanks
28  Game Development / Newbie & Debugging Questions / Re: IndexOutOfBounds index: 7 size: 7 NEED HELP on: 2013-02-03 22:47:33
This one works:
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  
ArrayList<Bullet> nulledBullets = new ArrayList<Bullet>();
   ArrayList<Enemy> nulledEnemys = new ArrayList<Enemy>();
   
   public void update(ArrayList<Enemy> e, EnemyController ec, Game game) {
      if (nulledEnemys.size() > 0) {
         for (Enemy nulledEnemy : nulledEnemys) {
            if (e.contains(nulledEnemy)) {
               e.remove(nulledEnemy);
            }
         }
         nulledEnemys.clear();
      }
      if (nulledBullets.size() > 0) {
         for (Bullet nulledBullet : nulledBullets) {
            if (b.contains(nulledBullet)) {
               b.remove(nulledBullet);
            }
         }
         nulledBullets.clear();
      }
      for (Bullet bullet : b) {
         if (b != null) {
            for (Enemy enemy : e) {
               if (enemy != null) {
                  if (bullet.getBounds().intersects(enemy.getBounds())) {
                     if (!nulledBullets.contains(bullet)) {
                        nulledBullets.add(bullet); // THIS WILL REMOVE BULLETS.
                    }
                     // removeBullet(bullet); <--- REMOVED
                    game.enemyHealth--;
                     if (game.enemyHealth <= 0) {
                        if (!nulledEnemys.contains(enemy)) {
                           nulledEnemys.add(enemy); // THIS WILL REMOVE ENEMYS.
                       }
                        // ec.removeEnemy(enemy); <--- REMOVED
                       game.score++;
                     }
                  }
               }
            }
            bullet.update(e);
         }
      }
   }
29  Game Development / Newbie & Debugging Questions / Re: IndexOutOfBounds index: 7 size: 7 NEED HELP on: 2013-02-03 22:45:10
Thank you so much. its working now Smiley [Just not sure how that works though.] would you mind maybe explain it. if not its fine
30  Game Development / Newbie & Debugging Questions / Re: IndexOutOfBounds index: 7 size: 7 NEED HELP on: 2013-02-03 22:38:51
i am getting yet another ConcurrentModificationException
Pages: [1] 2
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (108 views)
2013-05-17 21:29:12

alaslipknot (117 views)
2013-05-16 21:24:48

gouessej (146 views)
2013-05-16 00:53:38

gouessej (141 views)
2013-05-16 00:17:58

theagentd (154 views)
2013-05-15 15:01:13

theagentd (138 views)
2013-05-15 15:00:54

StreetDoggy (182 views)
2013-05-14 15:56:26

kutucuk (206 views)
2013-05-12 17:10:36

kutucuk (205 views)
2013-05-12 15:36:09

UnluckyDevil (212 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.445 seconds with 20 queries.