Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (527)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (594)
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 / Game Mechanics / Re: 2D tile random map generation on: 2014-11-27 22:49:38
What i currently do do pull noise (im also following these guys work http://www.java-gaming.org/index.php?topic=31637.0 ) is doing this function, how would i go about the seed business?

public static float[][] generateSimplexNoise(int width, int height) {
      float[][] simplexnoise = new float[width][height];
      float frequency = 5.0f / (float) width;

      for (int x = 0; x < width; x++) {
         for (int y = 0; y < height; y++) {
            simplexnoise
  • [y] = (float) noise(x * frequency, y * frequency);
            simplexnoise
  • [y] = (simplexnoise
  • [y] + 1) / 2;
         }
      }

      return simplexnoise;
   }
2  Game Development / Game Mechanics / Re: 2D tile random map generation on: 2014-11-27 22:19:20
Is there a way of doing this but with a seed generation? so as the player progresses they can continue to expand the map rather then it being generated once
3  Game Development / Game Mechanics / Re: Best way to save maps (2D) and how to achieve it on: 2014-11-27 17:49:30
What would be the best way to format it? and how efficient is it handling a few thousand tiles? or groups of tiles
4  Game Development / Game Mechanics / Best way to save maps (2D) and how to achieve it on: 2014-11-27 17:43:12
I have been looking around at how people are able to save maps in games and i have came across 3 diffrent ways.

1) saving each tile as a pixel on a image: this way is basic and easy to do but there are some limitations. 1, filesize can get large if you try and save data in the gray scale value and you can only render a game from x0 - ~ and y0 - ~ and you cant use -1 quadrants, so this wont alow you to make a fully freerome game because 2 up and left will be limited.

2)Hard coding levels: i have found this only works with small puzzle type games and such and has the same flaws as the first type.

3) lastly, a map file, this would allow you to use things such as (1,-2){} to pull specific quadrates and get information on the tile type, metadata etc.

I am looking to use the 3rd method in a game i am working on but i cant find a good, small libery for saving and loading tiles, dose anyone have any suggestions? and alos allow me to not only save the tile ID but also meta data.

- John
5  Game Development / Game Mechanics / 2D tile random map generation on: 2014-11-27 15:17:14
I have been reading through this article ( http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/ ) on how to make a polygon map generation but i have no idea how to even go about doing this, any suggestions?

The way i want my map format to be saves is each pixie will be a tile in the game based on its hex value (Would be converted to a .data file in the future)

6  Game Development / Game Play & Game Design / Developing a new free roam 2D game (Team needed) on: 2013-03-17 11:28:26
I am looking for a dev team to help make a new type of free roam game that the player can play for hours unlocking new items, quests and arias, at the minute i have only just started working on 2D games and have came up with this mock up:



the graphics are going to be made by 2 artists that i have known for the past year.

In java i have a good knowledge of 2D rendering and 2D Gui interfaces so we should be covered there.

If you have any questions just drop me a Pm or a comment.
7  Game Development / Newbie & Debugging Questions / Block colision detection problems(off centered) on: 2013-03-16 15:14:52
The problem i am having is when making the games block colliton center onto the blocks and for some reason the colision box is a few blocks NW from where it should be.
Player file:
package com.AdamWalters.com.zain.mob;

import com.AdamWalters.com.zain.Level.Level;
import com.AdamWalters.com.zain.Level.tiles.Tile;
import com.AdamWalters.com.zain.graphics.Screen;
import com.AdamWalters.com.zain.graphics.Sprite;
import com.AdamWalters.com.zain.input.InputHandler;

public class Player extends Mob {

   private InputHandler input;
   private Sprite sprite;
   private int anim = 0;
   private boolean walking = false;
   
   static final int maxHealth = 2000;
   static int health = 2000;

   int speed = 40;
   
   public Player(Level level, int x, int y, InputHandler input) {
        super(level, "Player", x, y, 1);
        this.input = input;
        sprite = Sprite.player_forward;
    }


   public void update() {
      boolean running;
      int xa = 0, ya = 0;
      if (anim < 7500)
         anim++;
      else
         anim = 0;
      if (input.shift){
         running = true;
         speed  = 20;
      }else{
         running = false;
         speed  = 40;
      }
      if (input.up&&running)
         ya--;
      if (input.down&&running)
         ya++;
      if (input.left&&running)
         xa--;
      if (input.right&&running)
         xa++;
      
      if (input.up)
         ya--;
      if (input.down)
         ya++;
      if (input.left)
         xa--;
      if (input.right)
         xa++;

      if (xa != 0 || ya != 0) {
         move(xa, ya);
         walking = true;
      } else {
         walking = false;
      }
   }

   public void render(Screen screen) {
      int flip = 0;
      if (dir == 2) {
         sprite = Sprite.player_forward;
         if (walking) {
            if (anim % speed > speed/2) {
               sprite = Sprite.player_forward_1;
            } else {
               sprite = Sprite.player_forward_2;

            }
         }
      }
      if (dir == 1) {
         sprite = Sprite.player_side;
         if (walking) {
            if (anim % speed > speed/2) {
               sprite = Sprite.player_side_1;
            } else {
               sprite = Sprite.player_side_2;
            }
         }
      }
      if (dir == 0) {
         sprite = Sprite.player_back;
         if (walking) {
            if (anim % speed > speed/2) {
               sprite = Sprite.player_back_1;
            } else {
               sprite = Sprite.player_back_2;
            }
         }
      }

      if (dir == 3) {
         sprite = Sprite.player_side;
         if (walking) {
            if (anim % speed > speed/2) {
               sprite = Sprite.player_side_1;
            } else {
               sprite = Sprite.player_side_2;
            }

         }
         flip = 1;
      }//this has to be changed for the player sprite. e.g. 16 for 32 * 32 sprites and 32 for 16 * 16 sprites.
      screen.renderPlayer(x - 16, y - 16, sprite, flip);
   }
   
   public boolean hasCollided(int xa, int ya) {
        int xMin = 0;
        int xMax = 15;
        int yMin = 7;
        int yMax = 15;
        for (int x = xMin; x < xMax; x++) {
            if (isSolidTile(xa, ya, x, yMin)) {
                return true;
            }
        }
        for (int x = xMin; x < xMax; x++) {
            if (isSolidTile(xa, ya, x, yMax)) {
                return true;
            }
        }
        for (int y = yMin; y < yMax; y++) {
            if (isSolidTile(xa, ya, xMin, y)) {
                return true;
            }
        }
        for (int y = yMin; y < yMax; y++) {
            if (isSolidTile(xa, ya, xMax, y)) {
                return true;
            }
        }
        return false;
    }

   public static int getHealthPersentage() {
      int persentage;
      persentage = (health/100)/maxHealth;
      return persentage;
   }
   public static int maxHealth(){
      return maxHealth;
   }
   public static int health(){
      return health;
   }
   public static void addDamage(int damage){
      health = health - damage;
   }

}

mob file:
package com.AdamWalters.com.zain.mob;

import com.AdamWalters.com.zain.Level.Level;
import com.AdamWalters.com.zain.Level.tiles.Tile;
import com.AdamWalters.com.zain.entity.Entity;
import com.AdamWalters.com.zain.graphics.Sprite;

public abstract class Mob extends Entity {

   protected Sprite sprite;
   protected int dir = 0;   // 0 = north, 1 = east, 2 = south, 3 = west
   protected boolean moving = false;
   int speed;
   
   public Mob(Level level, String name, int x, int y, int speed) {
        super(level);
        this.x = x;
        this.y = y;
        this.speed = speed;
    }
   
   
   public void move(int xa, int ya) {
      if (xa > 0) dir = 1;
      if (xa < 0) dir = 3;
      if (ya > 0) dir = 2;
      if (ya < 0) dir = 0;
      
        if (!hasCollided(xa, ya)) {
            if (ya < 0)
                dir = 0;
            if (ya > 0)
               dir = 2;
            if (xa < 0)
               dir = 3;
            if (xa > 0)
               dir = 1;
            x += xa * 1;
            y += ya * 1;
        }
   }
    public abstract boolean hasCollided(int xa, int ya);
   protected boolean isSolidTile(int xa, int ya, int x, int y) {
        if (level == null) {
            return false;
        }
        Tile lastTile = level.getTile((this.x + x) >> 7, (this.y + y) >> 7);
        Tile newTile = level.getTile((this.x + x + xa) >> 7, (this.y + y + ya) >> 7);
        if (!lastTile.equals(newTile) && newTile.isSolid()) {
            return true;
        }
        return false;
    }

   public void update() {
   }
   
   public void render() {
   }
   
}

level file:
package com.AdamWalters.com.zain.Level;

import com.AdamWalters.com.zain.graphics.Screen;
import com.AdamWalters.com.zain.Level.tiles.Tile;

public class Level {
   
   protected static int width;
   protected static int height;
   protected int[] tilesInt;
   protected static int[] tiles;
   
   public static Level spawn = new SpawnLevel ("/levels/level.png");
   
   public Level(int width, int height) {
      this.width = width;
      this.height = height;
      tilesInt = new int [width * height];
      generateLevel();
   }
   
   public Level(String path) {
      loadLevel(path);
      generateLevel();
   }

   protected void generateLevel() {
   }
   
   protected void loadLevel(String path) {
   }

   public void tick() {
   }
   
   @SuppressWarnings
   ("unused") private void time() {
   }
   
   public void render(int xScroll, int yScroll, Screen screen) {
      
        if (xScroll < 0)
           xScroll = 0;
        if (xScroll > ((width << 3) - screen.width))
           xScroll = ((width << 3) - screen.width);
        if (yScroll < 0)
           yScroll = 0;
        if (yScroll > ((height << 3) - screen.height))
           yScroll = ((height << 3) - screen.height);
      
      screen.setOffset(xScroll, yScroll);
      /** >> 4 = /16 **/
      int x0 = xScroll >> 4;
      int x1 = (xScroll + screen.width + 16) >> 4;
      int y0 = yScroll >> 4;
      int y1 = (yScroll + screen.height + 16) >> 4;
      for (int y = y0; y < y1; y++) {
         for (int x = x0; x < x1; x++) {
            getTile(x, y).render(x, y, screen);
         }
      }
   }
   //Grass = 0xFF00 / 0x00FF00
   //Flower = 0xFFFF00
   //Rock = 0x878787
   //first two ff = 100% opaque & first two 00 = 100% transparent.
   public Tile getTile(int x, int y) {
      if (x < 0 || y < 0 || x >= width || y >= height){
         return Tile.voidTile;
      }
      if (tiles[x + y * width] == Tile.col_spawn_grass){
         return Tile.grass;
      }
      if (tiles[x + y * width] == Tile.col_spawn_log){
         return Tile.log;
      }
      if (tiles[x + y * width] == Tile.col_spawn_leaves){
         return Tile.leaves;
      }
      return Tile.voidTile;
   }
   public static int getTileID(int x, int y) {
      if (x < 0 || y < 0 || x >= width || y >= height){
         return 1;
      }
      if (tiles[x + y * width] == Tile.col_spawn_grass){
         return 2;
      }
      if (tiles[x + y * width] == Tile.col_spawn_log){
         return 3;
      }
      if (tiles[x + y * width] == Tile.col_spawn_leaves){
         return 4;
      }
      return 1;
   }
   

}
if anyone has  a solution to this it would be  appreciated if you left me a message or drop me a skype PM at :mythirdleg35
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.

PocketCrafter7 (14 views)
2014-11-28 16:25:35

PocketCrafter7 (10 views)
2014-11-28 16:25:09

PocketCrafter7 (11 views)
2014-11-28 16:24:29

toopeicgaming1999 (76 views)
2014-11-26 15:22:04

toopeicgaming1999 (67 views)
2014-11-26 15:20:36

toopeicgaming1999 (17 views)
2014-11-26 15:20:08

SHC (30 views)
2014-11-25 12:00:59

SHC (28 views)
2014-11-25 11:53:45

Norakomi (32 views)
2014-11-25 11:26:43

Gibbo3771 (28 views)
2014-11-24 19:59:16
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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