Jump to content
  • Advertisement

Search the Community

Showing results for tags 'Java'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Audio
    • Music and Sound FX
  • Business
    • Business and Law
    • Career Development
    • Production and Management
  • Game Design
    • Game Design and Theory
    • Writing for Games
    • UX for Games
  • Industry
    • Interviews
    • Event Coverage
  • Programming
    • Artificial Intelligence
    • General and Gameplay Programming
    • Graphics and GPU Programming
    • Engines and Middleware
    • Math and Physics
    • Networking and Multiplayer
  • Visual Arts
  • Archive


  • Audio
  • Visual Arts
  • Programming
  • Writing


  • Game Dev Loadout
  • Game Dev Unchained


  • Game Developers Conference
    • GDC 2017
    • GDC 2018
  • Power-Up Digital Games Conference
    • PDGC I: Words of Wisdom
    • PDGC II: The Devs Strike Back
    • PDGC III: Syntax Error


  • Audio
    • Music and Sound FX
  • Business
    • Games Career Development
    • Production and Management
    • Games Business and Law
  • Game Design
    • Game Design and Theory
    • Writing for Games
  • Programming
    • Artificial Intelligence
    • Engines and Middleware
    • General and Gameplay Programming
    • Graphics and GPU Programming
    • Math and Physics
    • Networking and Multiplayer
  • Visual Arts
    • 2D and 3D Art
    • Critique and Feedback
  • Community
    • GameDev Challenges
    • GDNet+ Member Forum
    • GDNet Lounge
    • GDNet Comments, Suggestions, and Ideas
    • Coding Horrors
    • Your Announcements
    • Hobby Project Classifieds
    • Indie Showcase
    • Article Writing
  • Affiliates
    • NeHe Productions
    • AngelCode
  • Topical
    • Virtual and Augmented Reality
    • News
  • Workshops
    • C# Workshop
    • CPP Workshop
    • Freehand Drawing Workshop
    • Hands-On Interactive Game Development
    • SICP Workshop
    • XNA 4.0 Workshop
  • Archive
    • Topical
    • Affiliates
    • Contests
    • Technical
  • GameDev Challenges's Topics
  • For Beginners's Forum


  • Community Calendar
  • Games Industry Events
  • Game Jams
  • GameDev Challenges's Schedule


There are no results to display.

There are no results to display.

Product Groups

  • Advertisements
  • GameDev Gear

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



About Me







Found 130 results

  1. Zemlaynin

    The Great Tribes Devblog #32

    Hello dears! It's been a month and a half since my last diary, a huge amount of work has been done during this time. So that was my task sheet, without considering the tasks that I perform on in-game mechanics: All tasks were performed not in the order in which they were located in the list, and there are no small tasks that had to be solved along the way. Many of the tasks did not concern my participation, such as Alex slowly changed to buildings: Work on selection of color registration of a terrane: The option that we have chosen to date will show a little below. The first thing I had the task of implementing shadows from objects on the map and the first attempts to implement through Shadow map gave this result: And after a short torment managed to get this result: Next, the task was to correct the water, pick up her good textures, coefficients and variables for better display, it was necessary to make the glare on the water: At the same time, our small team joined another Modeler who made us a new unit: The model was with a speculator card, but the support of this material was not in my engine. I had to spend time on the implementation of special map support. In parallel with this task it was necessary to finish lighting at last. All as they say, clinging to one another, had to introduce support for the influence of shadows on the speculator: And to make adjustable light source to check everything and everything: As you can see now there is a panel where you can control the position of the light source. But that was not all, had to set an additional light source simulating reflected light to get a more realistic speculator from the shadow side, it is tied to the camera position. As you can see the armor is gleaming from the shadow side: Wow how many were killed of free time on the animation of this character, the exact import of the animation. But now everything works fine! Soon I will record a video of the gameplay. Meanwhile, Alexei rolled out a new model of the mine: To make such a screenshot with the approach of the mine had to untie the camera, which made it possible to enjoy the views: In the process of working on the construction of cities, a mechanism for expanding the administrative zone of the city was implemented, in the screenshot it is indicated in white: I hope you read our previous diary on the implementation of visualization system for urban areas: As you may have noticed in the last screenshot, the shadows are better than before. I have made an error in the calculation of shadows and that the shadows behind the smallest of objects and get the feeling that they hang in the air, now the shadow falls feel more natural. The map generator was slightly modified, the hills were tweaked, made them smoother. There were glaciers on land, if it is close to the poles: A lot of work has been done to optimize the display of graphics, rewritten shaders places eliminating weaknesses. Optimized the mechanism of storage and rendering of visible tiles, which gave a significant increase and stable FPS on weak computers. Made smooth movement and rotation of the camera, completely eliminating previously visible jerks. This is not a complete list of all solved problems, I just do not remember everything Plans for the near future: - The interface is very large we have a problem with him and really need the help of specialists in this matter. - The implementation of the clashes of armies. - The implementation of urban growth, I have not completed this mechanism. - Implementation of the first beginnings of AI, maneuvering the army and decision-making and reaction to the clash of enemy armies. - The implementation of the mechanism storage conditions of the relationship of AI to the enemies, diplomacy. - AI cities. Thank you for your attention! Join our group in FB: https://www.facebook.com/groups/thegreattribes/
  2. Hey everyone I am looking for JAVA DEVELOPERS & WEB DEVELOPERS! 🤓 Project Summary: Basic Requirements: (you'll be further tested once established) Why do I need a web developer?: CONTACTS:
  3. I have a player who's rotation is y-axis only and controled by a function which sets a new rotation variable to the new value. What I need to figure out is which direction to turn, so the player has to move the least. What messes me up is the fact that degrees are 0-360. Anything that dosen't have to go past the 0/360 point works fine. My variables are the current rotation, and the wanted rotation. Any ideas? Thanks
  4. I'm totally new to Game Dev. and i wanna say "its not difficult", but sometimes i get stuck in tiny holes with nothing to dig my way out. Basically, I've been following this Java OpenGL (using JOGL) 2D series on YouTube for a while, as an attempt at my first game in java. But clearly its not going well. I followed the series up till episode 18, but after that; in episode 19, the tutor had implemented a KeyListener in order to move the player around. I did the same thing he did, but when i hold down the up/down/right or left key, the player moves for a bit but stops after like 2 seconds. For it to move again, i have to release the key and hold it down again. I personally think this is a problem with JOGL (the library I'm using). But would like to have a solution to the problem since I have already gone through the trouble of making an entire game engine. Anyways, here's the link to the video: Java OpenGL 2D Game Tutorial - Episode 19 - Player Input The code i used for player input is exactly similar to the one used by the tutor! Thanks...
  5. I'm trying to render a player texture on top of a TiledMap in LibGDX, my issue is that the map renders correctly, but the player texture is way larger than it should be. I'm sure it has something to do with my lack of understanding of the camera/viewport system, but I can't quite figure it out. game.unitsPerTile = 32 in this case. The texture in question is 32x64. public class GameScreen implements Screen { final Engine2D game; private OrthographicCamera camera; static final int GAME_WIDTH = 100; static final int GAME_HEIGHT = 100; private TiledMap map; private OrthogonalTiledMapRenderer mapRenderer; private Player player; public GameScreen(Engine2D game) { this.game = game; float screenWidth = Gdx.graphics.getWidth(); float screenHeight = Gdx.graphics.getHeight(); float aspectRatio = screenHeight/screenWidth; camera = new OrthographicCamera(30,30*aspectRatio); map = new TmxMapLoader().load("Map1.tmx"); mapRenderer = new OrthogonalTiledMapRenderer(map,1/game.unitsPerTile); TiledMapTileMapObject startPoint = (TiledMapTileMapObject)map.getLayers().get("Objects").getObjects().get("startZone"); player = new Player(); player.setPositionX(startPoint.getX()/game.unitsPerTile); player.setPositionY(startPoint.getY()/game.unitsPerTile); } @Override public void render(float delta) { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); game.batch.setProjectionMatrix(camera.combined); camera.position.x = player.getPositionX() + camera.viewportWidth/2; camera.position.y = player.getPositionY() + camera.viewportHeight/2; // tell the camera to update its matrices. camera.update(); mapRenderer.render(); mapRenderer.setView(camera); // begin a new batch and draw the bucket and // all drops game.batch.begin(); game.batch.draw(player.getTexture(),player.getPositionX(),player.getPositionY()); game.batch.end(); } }
  6. Zemlaynin

    The Great Tribes DevBlog #31

    Hello dears! In this short extraordinary diary we decided to tell you about the new system of city expansion, which was added to the game. As you may remember, the original structure of urban areas had a pronounced square structure: To begin with, this was quite enough, but since this graphic element was quite conspicuous and caused natural questions from some users, it was decided to give it a more meaningful form, especially since it was already in our immediate plans. To do this, it was necessary to develop a set of urban areas and their parts, which would give the growing city a visually more natural and pleasant look, as well as the logic of their interrelations. The end result is a set of models that, in theory, should take into account all possible expansion options for flat terrain: Now the starting version of the city looks like this: As you can see, due to additional extensions of residential areas, which are not actually them and serve only for decoration, the city got a more natural and visually pleasing silhouette. For those who are interested in the logic of the use of district models in the expansion of cities, under the spoiler will be attached a number of technical screenshots with explanations: The initial version of the residential area: To smooth its square appearance, additional elements are added to it. These elements, as noted above, are not independent areas, but serve only as a graphic design: The city can expand in any direction. For example, suppose the following urban area appears to the right of an existing one. The current right extension will disappear, and the following type of area will appear in its place: If the area appears at the bottom left diagonally, it will have a square shape, and its additional extensions the following form: If the area is built on top of the original, the city takes the following form: Built a lower right diagonal from the starting. The second built area is replaced by another modification, and an additional area from the bottom to the U-shaped: Although all possible options for development are not clearly presented here, following this logic, theoretically, allows you to build cities of any possible form. Summarizing, you can see a screenshot of a large city, built in the game in this way: As an added bonus, a screenshot of the Outpost: Thank you all for your attention and see you soon!
  7. TheRebel47

    Shooting a ball in java

    I want to create a simple 2D Java game , where I should be able to shoot a ball with a character (with a spritesheet). The problem is, I don't know which classes or which methods i would need. I thought of using a physics engine called "dyn4j", but actually i don't know much about it and my researches about it failed. I just found some examples of some games, where I looked for a shoot program, but I couldn't find anything: https://github.com/dyn4j/dyn4j-samples/tree/master/src/main/java/org/dyn4j/samples. The shot should be realistic as possible and of course collisions should also be handled. I also thought to use a mathematical function that resembles a parabola for the shot, but I think there should be an easier way. Do you think i should use dyn4j or another physics engine? Which classes or methods would help?
  8. I have a method that's gotten rather bloated and unwieldy. This is mostly because I ended embedding a switch-statement inside another switch-statement. The outer switch-statement could be swapped with an if-statement, but that doesn't seem like it would help much. I selected this method in particular because all of the switch-cases do very very similar things, and it seems like I may be able to simplify the method. To explain the method a bit: I have a Bandit class that holds various things like the bandit's physical stats, and includes custom Item class objects that represent what sort of weapons and armor the bandit is equipped with. Each type of Item can only be equipped once, since each bandit can only wield one weapon, wear one helmet, use one shield, or wear one leather-jerkin of course. So, if I want to equip an Item and an Item of that same type is already equipped, I have to take it off the bandit and put it in storage before I can equip the new Item. This method just handles equipping bandits. I have another that removes equipment. My Class Order: Weapon and Armor are both subclasses of Item. I use the Armor class attribute String armorType to determine what type of armor is being utilized. My Method: /** * Equips a bandit with the given Item parameter * @param item The Item to equip */ public void equipBandit(Item item) { // get the item's simple class name. String equipmentType = item.getTypeName(); switch(equipmentType) { case "Weapon": if(this.weapon == null) { this.weapon = item; } else { // increment the amount owned of the un-equipped weapon Main.organ.addAmount(this.weapon, 1); // decrement the amount owned of the equipped weapon Main.organ.addAmount(item, -1); // equip the weapon this.weapon = item; } break; case "Armor": Armor armor = (Armor) item; String armorType = armor.getArmorType(); switch(armorType) { case "torso": if(this.torsoArmor == null) { this.torsoArmor = item; } else { // Does the same things as the else statement above Main.organ.addAmount(this.torsoArmor, 1); Main.organ.addAmount(item, -1); this.torsoArmor = item; } break; case "head": if(this.headArmor == null) { this.headArmor = item; } else { Main.organ.addAmount(this.headArmor, 1); Main.organ.addAmount(item, -1); this.headArmor = item; } break; case "shield": if(this.shieldArmor == null) { this.shieldArmor = item; } else { Main.organ.addAmount(this.shieldArmor, 1); Main.organ.addAmount(item, -1); this.shieldArmor = item; } break; default: throw new IllegalArgumentException("Armor type not found"); } break; default: throw new IllegalArgumentException("Invalid Item"); } }
  9. 0 down vote favorite how to properly link an OrthographicCamera to a OrthogonalTiledMapRenderer How do I properly link an OrthographicCamera to a OrthogonalTiledMapRenderer? I have tiled map i'd like render and two stages that have actors on them.. I call render.render() in my screens render method as well as stages.draw(); but every i put render.setView(camera) the screen displayed flashes or does other weird things. How do I properly attach a moveable camera to a tiled map renderer? I render the map first, do game logic and then call draw on the stages. when I call translate on the camera the tiled map zooms way out for some reason? here is my render method public void render(float delta) { Gdx.gl.glClearColor(1, 0, 0, 1); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.update(); renderer.render(); gameLogic(); backStage.act(); // acts are called but do nothing frontStage.act(); frontStage.draw(); backStage.draw(); } here is where the camera and renderer get created public void addMap(GameMap map){ this.map=map; maps.add(map); renderer=new OrthogonalTiledMapRenderer(map.getTiledMap(), 1/20f); camera= new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); float aspect = Gdx.graphics.getWidth()/Gdx.graphics.getHeight(); camera.setToOrtho(false, 20*aspect, 20*aspect); renderer.setView(camera); frontStage= new Stage(); backStage=new Stage(); xSize=map.getXSize(); ySize=map.getYSize(); Gdx.input.setInputProcessor(this); }
  10. I need some advice on how to display moving animations with a tiled based RPG. I'm using libGDX as the UI frame work. So for the animations do I draw the actor of the solider enemy or other moving thing image once per draw call in th render method and change frames each draw call and slowly move it from tile tile to tile? or slowly move it from tile to tile during a single draw call and render loop pass and change frames in a single for loop? Using the former I can see problems with 2 objects trying occupying the same tile and the latter doesn't make much sense. I want some actors to be faster than others so they can out run them, would not using tile based movement be better and just forget on / off tiles for the living actors that move?
  11. jakethesnake

    Songs of Syx

    Hello. This is what I've been working on the past 5 years, using java and opengl. It's what I call a city-state simulator, where you build a city and conquer others. Its like Caesar II with a touch of Rome Total war. I've got a trailer here: youtube I've got me some social promotion: twitter And a webpage I'd love to hear what someone else thinks. Would you want to play this? Be harsh!
  12. I have a project with a bunch of different .java files. Is there a way for me to organize them in eclipse while still allowing them to access each other? If I split the project in different folders, Eclipse can't find the different files when they're called in a different file.
  13. Context I recently started reading the book Artificial Intelligence for Humans, Volume 1: Fundamental Algorithms by Jeff Heaton. Upon finishing reading the chapter Normalizing Data, I decided to practice what I had just learnt to hopefully finally understand 100 % of a special algorithm : equilateral encoding. Equilateral Encoding The purpose of this algorithm is to normalize N categories by creating an equilateral triangle of N - 1 dimensions. Each vertex in that triangle is a category and so, because of the properties of the equilateral triangle, it's easy to construct this structure with medians of 1 unit. For selecting a category, all you need is a location vector of N - 1 dimensions that's ideally inside the equilateral triangle. For example, consider the vertex C and point c. The vertex C is 100% of a specified category, whilst the point c is 0% of that category. The vertices A and B are also 0% of C's category. In other words, the further away a location vector is from a vertex along its median axis, the less it belongs to the vertex`s category. Also, if the mentioned axis distance is greater than the length of a median (all medians have the same length in an equilateral triangle, which is the range of values in this context), then the location vector absolutely does not belong to the specified category. The reason why we just don't select directly a category is because this algorithm is originally for machine learning. It quantifies qualitative data, shares the blame better and uses less memory than simpler algorithms, as it uses N - 1 dimensions. The Application First of, here's the link to my application : https://github.com/thecheeselover/image-recognition-by-equilateral-encoding How It Works To be able to know the similarities between two images, a comparison must be done. Using the equilateral encoding algorithm, a pixel versus pixel comparison is the only way to do so and thus shapes do not count towards the similarities between the two images. What category should we use to compare images? Well, colors of course! Here are the colors I specified as categories : Red Green Blue White Black The algorithm will select the closest category for each pixel according to the differences between both colors and save it's location vector in an array. Then, when both images are loaded, compare each image pixels against each other by computing the median distance, as mentioned before, between both of them. Simply project the first pixel's vector onto the other one and compute the Euclidean distance to get the median distance. Sum all computed median distances This way, it would also works if there were location vectors not totally on a vertex, even though it doesn't happen for the just described comparison algorithm. Preliminaries Of course, this can be really slow for immense images. Downscale the images to have a maximum width and height, 32 pixels in my case. Also, remove the transparency as it is not a color component in itself. If both images do not have the same aspect ratio and so not the same downscaled dimensions, then consider using extremely different location vectors and so just different categories for "empty" pixels against non-empty pixels. The Code The equilateral encoding table : package org.benoitdubreuil.iree.model; import org.benoitdubreuil.iree.utils.MathUtils; /** * The image data for the image recognition by equilateral encoding. * <p> * See the author Jeff Heaton of this algorithm and his book that contains everything about it : * <a href="https://www.heatonresearch.com/book/aifh-vol1-fundamental.html">Artificial Intelligence for Humans, Vol 1: Fundamental Algorithms</a> * <p> * The base source code for the equilateral encoding algorithm : * <a href="https://github.com/jeffheaton/aifh/blob/master/vol1/java-examples/src/main/java/com/heatonresearch/aifh/normalize/Equilateral.java">Equilateral.java</a> */ public class EquilateralEncodingTable { // The algorithm with only one category does not make sense private static final int MIN_CATEGORIES_FOR_ENCODING = 2; private int m_categoryCount; private int m_dimensionCount; private double m_lowestValue; private double m_highestValue; private double m_valueRange; private double[][] m_categoriesCoordinates; public EquilateralEncodingTable(int categoryCount, double lowestValue, double highestValue) { if (categoryCount < MIN_CATEGORIES_FOR_ENCODING) { throw new ArrayIndexOutOfBoundsException("Not enough categories for equilateral encoding"); } this.m_categoryCount = categoryCount; this.m_dimensionCount = computeDimensionCount(categoryCount); this.m_lowestValue = lowestValue; this.m_highestValue = highestValue; this.m_valueRange = highestValue - lowestValue; this.m_categoriesCoordinates = computeEquilateralEncodingTable(); } /** * Encodes a supplied index and gets the equilaterally encoded coordinates at that index. * * @param equilateralCoordsIndex The index at which the equilaterally encoded coordinates are. * * @return The equilaterally encoded coordinates. */ public double[] encode(int equilateralCoordsIndex) { return m_categoriesCoordinates[equilateralCoordsIndex]; } /** * Decodes the supplied coordinates by finding its closest equilaterally encoded coordinates. * * @param coordinates The coordinates that need to be decoded. It should not be equilateral it doesn't matter, as the goal is simply to find the closest equilaterally encoded * coordinates. * * @return The index at which the closest equilaterally encoded coordinates are. */ public int decode(double[] coordinates) { double closestDistance = Double.POSITIVE_INFINITY; int closestEquilateralCoordsIndex = -1; for (int i = 0; i < m_categoriesCoordinates.length; ++i) { double dist = computeDistance(coordinates, i); if (dist < closestDistance) { closestDistance = dist; closestEquilateralCoordsIndex = i; } } return closestEquilateralCoordsIndex; } /** * Computes the Euclidean distance between the supplied coordinates and the equilaterally encoded coordinates at the supplied index. * * @param coordinates Coordinates of the first n-dimensional vector. * @param equilateralCoordsIndex Index for the equilaterally encoded coordinates. * * @return The Euclidean distance between the two vectors. */ public double computeDistance(double[] coordinates, int equilateralCoordsIndex) { return MathUtils.computeDistance(coordinates, m_categoriesCoordinates[equilateralCoordsIndex]); } /** * Computes the equilateral encoding table, which is used as a look up for table for the data. * * @return The equilateral encoding table. */ private double[][] computeEquilateralEncodingTable() { double negativeReciprocalOfN; double scalingFactor; final double[][] matrix = new double[m_categoryCount][m_dimensionCount]; matrix[0][0] = -1; matrix[1][0] = 1.0; if (m_categoryCount > 2) { for (int dimension = 2; dimension < m_categoryCount; ++dimension) { // scale the matrix so far scalingFactor = dimension; negativeReciprocalOfN = Math.sqrt(scalingFactor * scalingFactor - 1.0) / scalingFactor; for (int coordinate = 0; coordinate < dimension; ++coordinate) { for (int oldDimension = 0; oldDimension < dimension - 1; ++oldDimension) { matrix[coordinate][oldDimension] *= negativeReciprocalOfN; } } scalingFactor = -1.0 / scalingFactor; for (int coordinate = 0; coordinate < dimension; ++coordinate) { matrix[coordinate][dimension - 1] = scalingFactor; } for (int coordinate = 0; coordinate < dimension - 1; ++coordinate) { matrix[dimension][coordinate] = 0.0; } matrix[dimension][dimension - 1] = 1.0; // Scale the matrix for (int row = 0; row < matrix.length; ++row) { for (int col = 0; col < matrix[0].length; ++col) { double min = -1; double max = 1; matrix[row][col] = ((matrix[row][col] - min) / (max - min)) * m_valueRange + m_lowestValue; } } } } return matrix; } public static int computeDimensionCount(int categoryCount) { return categoryCount - 1; } public int getCategoryCount() { return m_categoryCount; } public int getDimensionCount() { return m_dimensionCount; } public double getLowestValue() { return m_lowestValue; } public double getHighestValue() { return m_highestValue; } public double getValueRange() { return m_valueRange; } public double[][] getCategoriesCoordinates() { return m_categoriesCoordinates; } } The mathematics utilities : package org.benoitdubreuil.iree.utils; public final class MathUtils { /** * Computes the Euclidean distance between the supplied vectors. * * @param lhsCoordinates Coordinates of the first n-dimensional vector. * @param rhsCoordinates Coordinates of the second n-dimensional vector. * * @return The Euclidean distance between the two vectors. */ public static double computeDistance(double[] lhsCoordinates, double[] rhsCoordinates) { double result = 0; for (int i = 0; i < rhsCoordinates.length; ++i) { result += Math.pow(lhsCoordinates[i] - rhsCoordinates[i], 2); } return Math.sqrt(result); } /** * Normalizes the supplied vector. * * @param vector The vector to normalize. * * @return The same array, but normalized. */ public static double[] normalizeVector(double[] vector) { double squaredLength = 0; for (int dimension = 0; dimension < vector.length; ++dimension) { squaredLength += vector[dimension] * vector[dimension]; } if (squaredLength != 1.0 && squaredLength != 0.0) { double reciprocalLength = 1.0 / Math.sqrt(squaredLength); for (int dimension = 0; dimension < vector.length; ++dimension) { vector[dimension] *= reciprocalLength; } } return vector; } /** * Negates the vector. * * @param vector The vector to negate. * * @return The same array, but each coordinate negated. */ public static double[] negateVector(double[] vector) { for (int dimension = 0; dimension < vector.length; ++dimension) { vector[dimension] = -vector[dimension]; } return vector; } /** * Multiplies the vector by a scalar. * * @param vector The vector to multiply. * @param scalar The scalar by which to multiply the vector. * * @return The same array, but each coordinate multiplied by the scalar. */ public static double[] multVector(double[] vector, double scalar) { for (int dimension = 0; dimension < vector.length; ++dimension) { vector[dimension] *= scalar; } return vector; } /** * Computes the dot product of the two supplied points. * * @param lhsVector The first point. * @param rhsVector The second point. * * @return The dot product of the two points. */ public static double dotProductVector(double[] lhsVector, double[] rhsVector) { double dotResult = 0; for (int dimension = 0; dimension < lhsVector.length; ++dimension) { dotResult += lhsVector[dimension] * rhsVector[dimension]; } return dotResult; } private MathUtils() { } } The image data that shows how to encode pixels : package org.benoitdubreuil.iree.model; import org.benoitdubreuil.iree.controller.ControllerIREE; import org.benoitdubreuil.iree.gui.ImageGUIData; import org.benoitdubreuil.iree.pattern.observer.IObserver; import org.benoitdubreuil.iree.pattern.observer.Observable; import java.awt.*; import java.awt.image.BufferedImage; public class ImageData extends Observable<ImageData> implements IObserver<ImageGUIData> { private double[][] m_encodedPixelData; /** * Encodes the pixel data of the supplied image data. * * @param newValue The new value of the observed. */ @Override public void observableChanged(ImageGUIData newValue) { if (newValue.getDownScaled() != null) { encodePixelData(newValue); modelChanged(this); } } private void encodePixelData(ImageGUIData imageGUIData) { EquilateralEncodingTable encodingTable = ControllerIREE.getInstance().getEncodingTable(); EquilateralEncodingCategory[] categories = EquilateralEncodingCategory.values(); BufferedImage image = imageGUIData.getDownScaled(); int width = image.getWidth(); int height = image.getHeight(); m_encodedPixelData = new double[width * height][]; for (int x = 0; x < width; ++x) { for (int y = 0; y < height; ++y) { int orignalPixel = image.getRGB(x, height - 1 - y); int r = (orignalPixel >> 16) & 0xff; int g = (orignalPixel >> 8) & 0xff; int b = orignalPixel & 0xff; int minColorDistance = 255 * 3; int minColorDistanceCategory = 0; for (int category = 0; category < encodingTable.getCategoryCount(); ++category) { Color categoryColor = categories[category].getColor(); int colorDistance = Math.abs(r - categoryColor.getRed()) + Math.abs(g - categoryColor.getGreen()) + Math.abs(b - categoryColor.getBlue()); if (colorDistance < minColorDistance) { minColorDistance = colorDistance; minColorDistanceCategory = category; } } m_encodedPixelData[x * height + y] = encodingTable.encode(minColorDistanceCategory).clone(); } } } public int getPixelCount() { return m_encodedPixelData.length; } double[][] getEncodedPixelData() { return m_encodedPixelData; } } The actual image data recognition algorithm : package org.benoitdubreuil.iree.model; import org.benoitdubreuil.iree.controller.ControllerIREE; import org.benoitdubreuil.iree.utils.MathUtils; public final class ImageDataRecognition { /** * Compares two images and return how similar they are. * * @param lhs The first image to compare. * @param rhs The second image to compare. * * @return Inclusively from 0, totally different, to 1, the same. */ public static double compareImages(ImageData lhs, ImageData rhs) { double meanDistance = 0; double[][] lhsEncodedPixelData = lhs.getEncodedPixelData(); double[][] rhsEncodedPixelData = rhs.getEncodedPixelData(); if (lhsEncodedPixelData != null && rhsEncodedPixelData != null) { EquilateralEncodingTable table = ControllerIREE.getInstance().getEncodingTable(); int maxPixelCount = Math.max(lhs.getPixelCount(), rhs.getPixelCount()); double emptyPixelMeanValue = 1.0; for (int pixel = 0; pixel < maxPixelCount; ++pixel) { double[] lhsVector; double[] rhsVector; if (pixel < lhs.getPixelCount()) { lhsVector = lhsEncodedPixelData[pixel]; } else { meanDistance += emptyPixelMeanValue; continue; } if (pixel < rhs.getPixelCount()) { rhsVector = rhsEncodedPixelData[pixel]; } else { meanDistance += emptyPixelMeanValue; continue; } double rhsDotLhs = MathUtils.dotProductVector(rhsVector, lhsVector); double[] rhsProjectedOntoLhs = MathUtils.multVector(lhsVector.clone(), rhsDotLhs); meanDistance += MathUtils.computeDistance(lhsVector, rhsProjectedOntoLhs) / table.getValueRange() / maxPixelCount; } } return meanDistance; } private ImageDataRecognition() { } }
  14. Hi, I have a problem with my programm and i cant find any solution... I wrote a simple 2D game. The background is moving and accelerating slowly. On the right side there is the player, he is fixed and not movable. Now I want carrots moving with the same speed as the background towards the player. So i used the exact same speed like the background, but i set them as an Array List. Now the carrots spawn, they start with the same speed like the background, but then they get slower and slower instead of faster and faster. If i dont declare them as an ArrayList it works, but i want multiple carrots on the screen. Would be really nice if someone has an idea, Thank You!!!
  15. I want to be able to display an amount of gold at the top of the screen that changes based on how much the player buys. I can just remove and reload the Pane object in my screen controller class, but it seems like there must be a way for me to only update one part of a Pane without needing to reload the entire thing. How can I modify a variable and change it's displayed value in a window, while not reloading the entire Pane object? Main Class package application; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.Pane; import javafx.scene.text.Font; import javafx.scene.text.Text; import javafx.stage.Stage; public class Main extends Application { // Fonts public static final String IMPER_FONT = "./res/fonts/imperator.ttf"; // Global Images // used for screen titles public static final ImageView TITLE_IMG = makeImage("./res/images/title.png"); public static final ImageView HIDEOUT_IMG = makeImage("./res/images/hideout.png"); public static final ImageView TREASURY_IMG = makeImage("./res/images/treasury.png"); // Global Game Stats public static int Gold = 1250; public static LinkList<Object> Equipment = new LinkList<>(); // Panes private static Pane mainMenu = MainMenu.getPane(); private static Pane hideout = Hideout.getPane(); private static Pane treasury = Treasury.getPane(); // Screen Controller private static Scene scene = new Scene(mainMenu, 1600, 900); private static ScreenController control = new ScreenController(scene); /** * Creates an ImageView object * * @param path A String that represents the filepath to the image * @return ImageView An Imageview object with the appropriate image */ private static ImageView makeImage(String path) { FileInputStream input; try { input = new FileInputStream(path); ImageView title = new ImageView(new Image(input)); return title; } catch (FileNotFoundException e) { e.printStackTrace(); } return null; } /** * Creates a Text object with specified font file-path, message, and size. * * @param String path the file path of the font file * @param String message the text of the Text Object * @param double size the size of the font * @return Text The appropriate Text object. */ public static Text makeText(String path, String message, double size) { FileInputStream input; try { input = new FileInputStream(new File(path)); Font font = Font.loadFont(input, size); Text msg = new Text(message); msg.setFont(font); return msg; } catch (FileNotFoundException e) { e.printStackTrace(); } return null; } @Override public void start (Stage stage) { // Add panes to ScreenController object control.addScreen("main menu", mainMenu); control.addScreen("hideout", hideout); control.addScreen("treasury", treasury); // create the scene and display it stage.setScene(scene); stage.show(); } /** * Allows other classes to use the same ScreenController object. * * @return ScreenController The object used to switch screens */ public static ScreenController getControl() { return control; } public static void main(String[] args) { launch(args); } } ScreenController class package application; import java.util.HashMap; import javafx.scene.Scene; import javafx.scene.layout.Pane; public class ScreenController { private HashMap<String, Pane> screenMap = new HashMap<>(); private Scene main; public ScreenController(Scene main) { this.main = main; } protected void addScreen(String name, Pane pane) { screenMap.put(name, pane); } protected void removeScreen(String name) { screenMap.remove(name); } protected void activate(String name) { main.setRoot(screenMap.get(name)); } }
  16. For my assignment my professor has given me the option of either accessing the private attributes of an inner class directly, or making my own "set" methods for those attributes. I am not sure what is generally considered best in this case. I am not used to accessing private attributes directly, but I'm new to Java, and haven't used inner classes much before either. She's not going to take off points no matter what I do, so I hope this isn't considered, "homework help". Anyway, which do you feel would be best and/or most elegant?
  17. Forgive me for the somewhat inappropriate title for my question. I can't seem to keep my game objects in sync with a box2d body. I understand these much: 1. When you get a body position, you need to subtract half the size of your sprite to get the exact location 2. box2d uses radians for angles, so you need to convert to degrees. Everything was going well when I used CircleShape and PolygonShape's setAsBox() method to create my shapes, but when I created a triangle using my own vertices, the shape was drawn correctly but now my sprite is no longer following the body correctly. Please what am I doing wrong or what am I not doing?
  18. Zemlaynin

    The Great Tribes Devblog #1

    Concept Document Game project, a global strategy simulator of civilization development - The Great Tribes 1. Classification Genre: global strategy, simulator. Time of one walkthrough: 10 + hours. Platform: PC. 2. Main Features The Great Tribes is a global strategy simulator of civilization development, the action of which takes place in the historical period from 3000 BC to the beginning of 3000 AD. During the game the player will have to create their own unique civilization and try their hand at its development in a nonlinear, constantly changing world. Conceptually, the game is a cross between a turn-based strategy Sid Meier’s Civilization VI and strategies of Paradox Interactive (Crusaders, Europe and Victoria). Similarity with these games is limited to the time period covered in the game and some game mechanics. In our project we want to reflect the role of a personality in history, but instead of personalities history is influenced by different factions. We focus on working out in detail of various historical phenomena. We are planning to create an advanced economic system that will make it possible to simulate economic processes with a high degree of realism. The simulation of interaction between different countries includes: diplomatic relations, economic, technological, cultural and social influence. The conduct of military actions between the countries in our project will be realized in a wide range, from single collisions to waging a trench warfare at a vast front. Realistic simulation of the historical process The game model is based on the results of the latest research in various scientific fields: from history and political science to geology and agricultural sciences. Simulation allows to simulate all the significant historical phenomena and processes. Flexible Turn-based Gameplay System The calculation of the game turn is divided into a turn and a tick. The turn calculates global parameters: population and economy growth, migration of strata and changes in their characteristics, etc. During the game it is possible to change the time step depending on the player's preferences. Ticks only occur in combat. There are 4 ticks in the course of the turn: spring, summer, autumn and winter. Thus, the army that committed a long march-throw and entered the battle running out of action points will fight in the winter tick with the corresponding consequences. Advanced Technology System Technological discoveries occur randomly, and the probability depends on the accumulation of a corresponding number of technological points: agricultural, industrial, military or social. After the discovery, the technology is embedded into one or another technology package, which has an impact on a particular game system. Mechanics of technological packages allows to make development in the game realistic and not always predictable. Two-dimensional Social System The population in the game is grouped into strata and factions. Strata determines the place of the household in the labour division while the factions are responsible for the redistribution of power in the game. For example, the insufficient number of strata workers could hamper industrialization of the country and the trade union faction can fight for the rights of this small strata. Flexible Coalition System The coalition system allows to create various forms of relations between administrative units: an administrative zone and a region, a region and a country, between several countries (confederations, vassal relations, unions, etc.), between a region and an army (government armies, feudal armies, etc.). Realistic Economic System Economy in the game is a system based on the dynamic cost of resources, goods and services. This makes it possible to simulate a variety of regional specializations, economic imbalances, etc. Unique Political System The main elements of the political system in the game are the form of government, political values, laws and corruption. The form of government is based on the ratio of five elements: barbarism, community, democracy, oligarchy and monarchy. Changing the ratio of these elements, it is possible to simulate any existing or even a non-existent form of government. Political values reflect the position of the elite on each of the political or parapolitical issues. During the game the elite (of its own free will or under the pressure of the player) can change their values, but, as a rule, it is painful and not fast. Laws allow to carry out quite a fine adjustment of the country, and corruption can help to restrain the player from excessive expansion of their power. Diversity of Cultural and Civilization Forms Unlike other games, civilizations in the game are formed on the basis of 4 pairs of framework principles, which can form up to 16 unique civilizations, and their combination allows to generate up to 3520 unique cultures. Conduct of Military Operations The military aspect of the game focuses on the strategic management of armies: formation of military doctrines, establishment of the conduct strategy of armies, determination of the optimum correlation of branches of armed forces for this or that army, etc. The player will be able to concentrate on planning the strategy of the military campaign. 3. Gameplay The main task of the player is to develop their country in conditions of external threat and/or internal instability. By controlling a multitude of mechanisms, the player can implement any of the goals offered in the game: creation of the richest trading empire, holding power in the role of one ruling dynasty as long as possible, being the first to implement the industrial revolution, etc. 4. Game Map The game map is divided into tiles and subtiles. But this division is valid for the technical side of the game. In terms of gameplay, the map is divided into tiles only. Each tile occupies an area of 1369 sq. km (this value may change during balancing). Within this area on a tile there can be located districts (in the cities), buildings (outside the settlements), the tile can be divided into different types of biomes, etc. Depending on the biome, a certain amount of resources may be situated on the tile. So, it is advantageous to place fields on meadow plains, the area of which depends on the area of agricultural lands of the tile. In addition, each tile has a certain level of transport infrastructure, which defines the movement speed of armies and the capacity of trade caravans. However, unlike armies, caravans can move only along the main routes which are indicated on the map. This path can change its trajectory, depending on the quality of transport infrastructure of neighboring tiles, crime rates and other factors. The closer is the tile to the crime center (the settlement of the player or another country or a bandit/pirate settlement), the higher is its crime rate. On the map there constantly appear bandit armies, so they are exactly simulated by this parameter, only without the need to constantly drive armies across the country to destroy them. Rebel armies will be represented in the form of full armies. In addition to the transport infrastructure, there is a parameter of urban infrastructure. The urban infrastructure represents the level of development of various services and engineering networks of the settlement (accessibility and quality of utilities, communication facilities, urban transport, catering, retail, emergency services, etc.). Urban infrastructure is available not only in cities but also in villages. To create favorable conditions in the settlements the player will have to balance between the development of transport and urban infrastructure. 5. Administrative division and types of settlements The game has three levels of control: a country, region and administrative zone. An administrative zone is a territory with dynamic boundaries, being controlled by the settlement. Within this territory, residents of the settlement can build anything within the framework of the ongoing development programme. All types of settlements without exception have this zone, from villages to cities. If a city in the region forms a new region, all the tiles in its administrative zone also become part of the new region. Administrative zones are grouped into a larger formation – a region. A region is a territory with dynamic boundaries, consisting of a certain number of administrative zones. It necessarily includes the capital city of the region. Unlike the administrative zone, a region can simultaneously be a country (consisting of one region). In addition, the player can directly manage it (whereas administrative zones can be managed only through legislation). A country is the highest level of control in the game (not counting international coalitions), representing one region or a coalition of regions. A coalition means not the country's federal structure, but the system which defines relations between different administrative units in the game. Each country has a capital, and as a consequence - the capital region. The region of this type has the same functionality as a usual region, but in addition it hosts the highest state bodies: ministeries and the advisory board. Each level of management has its own central settlement. It can be a village (only for the administrative zone), city or encampment. A village is a type of settlement focused on food production or resource extraction. Over time a village can be upgraded into a city. The game presents 3 basic types of villages: agricultural, resource-extracting and military. An agricultural village is oriented to the processing of farmland. A resource-extracting village is focused on the extraction of minerals. The type of resources that are extracted depends on the demand for the resource. A military village generalizes a variety of villages, the inhabitants of which are hostile to the player. A rebel village: village troops will defend their village and their independence. A village becomes rebellious if the population's loyalty to power is too low. A bandit (pirates) village: village troops will attack the settlements and trade routes located nearby. A village prefers to move into this state due to absence of legal means to maintain an acceptable standard of living. The given types of villages are conventional. All villages have the same characteristics, but their chosen vector of development depends on the demand for a particular resource, or on the level of loyalty to power. New villages in the game can be formed either automatically or due to a certain decision. The place of automatic appearance of villages is determined on the basis of attractiveness of adjoining territories for processing, and also is located at a certain distance from other settlements and processed tiles. As the population of old settlements rises to some level, the chance of a new village emerging at some distance increases. Its population will not appear out of nowhere, but it migrates from the settlement. New villages can occur both inside and outside the region. Encampment is a type of settlement of nomadic cultures, able to move to other tiles. Settling, nomads form a village or city (depending on the size of the nomadic group). Unlike a city, playing for encampment is concentrated not so much on the management of the population, but on the management of tribal clans (factions). Each clan has its own encampment. The elite of each nomadic group includes every member of the clan. However, the encampment can include residents who are not part of the clan (slaves, mercenaries, etc.). The more solid (controlled) the clans are, the stronger the tribe is in clashes with other nations. This clan structure of the society is typical of all countries with barbaric elements of government. However, in settled states clans do not always act as the elite of the settlement. In addition, unlike cities, change of dominant elites in the tribe occurs not gradually through transfer of population from one faction to another, but via change of the fraction status. In game mechanics it is represented in the form of change of the capital nomads and status of the elite. Another distinguishing feature of nomads is their ability to move around the map. This is possible in two ways: moving the nomadic population of the ruling clan, while the rest of the nomads are moved in automatic mode (due to an insufficient level of control or by the decision of the player); moving all the nomads manually with a sufficient level of control. Poorly controlled nomads are moved in automatic mode. A city is a type of settlement with multiple forms of activity, but with a certain specialization. A city is not necessarily a result of the village development, but it can be built from scratch, or formed from the outpost (see Regional buildings). Unlike a village or encampment, a city that is the capital of a region or country can have up to three Wonders of the world (one of each level: regional, national and international). In the game there are many specializations of cities: Administrative center Science center Trade center Cultural center Religious center Industrial city The higher the city is placed in the hierarchy (a provincial city - the capital of the region - the capital of the country), the greater effect its specialization produces. So, if the player decided to build a huge empire, it is better to establish an administrative center as the capital (for the control of large territories), for a trading empire it should be a trade center, and for theocracy it is more preferable to assign a religious center of a state religion, etc. The difference between a city and a village: a city has a more developed social infrastructure; it occupies a certain area of the tile and when it is exceeded, it expands to a neighboring tile; a city creates an administrative load; it is possible to construct wonders of the world (in capitals); it has diverse stratification and division into districts. 6. Urban districts In the city, a player can build up to seven districts that can be expanded to accommodate various infrastructures: An administrative district performs functions of control and development of the administrative resource; An industrial district produces practically all types of goods (except luxury); A cultural district produces luxury goods, prestige, and also creates some modifiers for the city; A scientific district is responsible for increasing literacy of the population and accelerating the development of technologies; A religious district - the development of the district contributes to increasing the influence of state religion; A commercial district – transport and financial infrastructure is created here; A social district provides the population with housing and urban infrastructure. Six of the listed districts can be built in the city center and determine its specifics. In addition, the effect of all districts depends on the location of the city – it can be situated near the shore or in the depths of the continent. Characteristics of districts Cost includes resources needed for the region expansion. Content includes resources necessary for supply of the district during each turn. Workforce is the number of working hands required for the efficient operation of the district. Area is the area given and available for expansion. Effect stands for the bonus-malus payments, received in the course of functioning of the district. Wonders of the World Instead of usual constructions three types of wonders of the world are built in cities: regional, national and global. The effect of every kind of wonders is spread according to their scale. The list of wonders available for construction in the city depends on the central district of the city. And the effect produced by the district will be determined by the chosen wonder. In addition, the district can include up to three wonders, one of each level.However, construction of a higher-level wonder reduces the effect of wonders of a lower level. The wonder effect can also be reduced by the presence of a similar wonder in the zone of influence and visibility. The scale of the wonder influences its price and effect. In addition, the effect of a small wonder can easily disappear if certain conditions are not fulfilled, whereas the effect of a world wonder never disappears. 7. Regional buildings In addition to the wonders of the world and urban districts, the player can also build constructions outside the city - in regional and extraregional tiles. Characteristics of regional buildings: Cost stands for resources necessary for construction. Supply includes resources necessary for ensuring the construction during each turn. Workforce is the number of working hands required for an efficient operation of a building. Location defines whether it is possible to build a construction only within the district or everywhere. Improvement - some buildings can be rebuilt into other more significant constructions. For example, a wooden advance outpost can be upgraded into a stone one. Accommodation conditions - most buildings can be built only in tiles with certain conditions. Effect - buildings can produce a variety of effects: from ordinary bonuses to the ability to extract resources and supply armies. List of buildings Agricultural: gardens, a pasture, a field, a camp; Mining: a quarry, a sawmill, a mine, a drilling rig; Military: an outpost, a military base. Unlike other buildings, outposts can be installed outside the district. The outpost has its own control zone, which complicates the speed of enemy forces passing through it, and decreases the level of crime in the district. In addition, outposts with a sufficiently high level of development of urban infrastructure can be converted into a city or village. 8. Domestic Policy The key indicators of domestic policy are the administrative burden and the administrative resource. The administrative burden is the level of constant administrative spendings on the management of the country, as well as various actions of the player. The administrative burden of the country is the burden of the regions and the highest governmental structures. The administrative resource is the management resource which represents the number of civil cervants and their management efficiency. If the administrative load exceeds the administrative resource, the player begins to lose control over the regions. In addition, the administrative resource can be spent on corrupt practices. Corruption in the game is trade in administrative resource, carried out by the management apparatus. Like for any resource, the laws of supply and demand apply to the administrative resource. Strata that captured part of the administrative resource of the city, region or country get the opportunity to determine the actions of a chosen government institution. In addition to trade in the administrative resource, corruption is expressed in the form of an indicator of the region or government structures which determines the efficiency of budget spendings on their needs. Forms of Government Another important element of domestic policy is the form of government. It is a mixture of five elements: barbarism, community, democracy, oligarchy and monarchy. Each element can take a value from 0 to 10, where 0 is the absence of characteristics and 10 is its pure, pronounced characteristics. For example, a country may have the following form of government: barbarism (5), community (3) and oligarchy (2). Total expressiveness of all forms of government should be equal to 10, so to increase an element, for example, democracy one must reduce the strength of one of the remaining elements. Each of the elements of the form of government gives its own unique effect and when changing the form of rule the gameplay changes accordingly. Forms of government also give access to 1) certain social technologies. Some of the technologies are closed from some forms of government. For example, rooted barbarism closes access to tax collection and trade technologies. 2) to the laws For example, a strong monarchy gives an opportunity to pass a law on inheritance of power. Political values Political values reflect the standpoint of the strata and factions on each of the political or parapolitical issues. In the course of the game they (of their own will or under the player’s pressure) can change their values, but, as a rule, it is painful and not fast. The game has the following groups of values: Economy: a hard plan \ a soft plan \ pragmatism \ a regulated market \ a free market Openness of the society: closed \ moderately closed \ semi \ moderately open \ open Social Policy: state / state-society / society / society - individual \ individual Foreign Policy: isolationism \ non-interference\ realism \ interventionism \ expansionism Religious Policy: theocracy \ clericalism \ secularism \ anticlericalism \ militant atheism National Policy: nazism \ nationalism \ multiculturalism \ internationalism \ cospomolitism Post-values: denied \ invalid \ neutral \ minor \ important Post-values in the game reflect the attitude of people to the values of new, upcoming phases of development. For example, in the course of society's transition to the industrial phase of development, issues of emancipation of women, ecology and others became significant. The more loyal the society is to post-values, the more inclined it is to revise its other values, which can lead to social instability. The forms of government along with the political values of the elite allow to simulate all the basic forms of political formations. Laws If the forms of government tell us who rules the country, then the laws show how the country is ruled. Laws can be adopted both for the whole country and for each region separately. The adoption of any law entails a temporary decrease in the loyalty of regions. Besides, the laws are not just effects, but also constant expenses on their maintenance. The lack of resources for the maintenance of laws leads to the fact that laws cease to operate, starting from the recently introduced and ending with the most entrenched. Forms of struggle for power Finally, the domestic policy is expressed in the struggle for power. Depending on the prevailing contradictions between the authorities and the opposition, the latter may make various steps to change the current power: Change of the party of power (occurs in the form of cabinet struggle within the established norms) Civil disobedience Insurrection / Coup d'état Terrorism Civil war Guerrilla war Participants of the guerilla movement are the strata with the state religion and culture Peasant War The lower the position on the list is, the higher is the massiveness, the number of victims and the cruelty of speeches; the current rules and regulations are followed less and the speed of the process is higher, but, in case of success of the action, reforms conducted by the new power are more radical. 9. Foreign Policy Diplomacy and Prestige The basis of diplomatic relations in the game is the system of coalitions. Coalition agreements can be concluded between countries, between regions and even between the capital of the region and the settlements belonging to it. In fact, it is a universal pattern of establishing communication between administrative entities. The main resource of diplomacy is prestige. Prestige is a generalized measure of grandeur of an international organization, country, region or settlement. This parameter affects both the other administrative entities and the perception of any entity by the population. So, a city, producing a lot of prestige, can get a good income from tourism. And a country with high prestige can tempt other countries and regions over to its side. Espionage Espionage in the game is an agent network that is introduced into a particular region. The more developed the agent network is, the higher the chance of success of espionage actions or counteraction of foreign secret services is. 10. Demographics The population in the game is divided into strata and factions. Strata reflect the professional role of the population in the game, whereas the role of factions is to fight for power in any of its manifestations. Strata The game presents the following strata: Peasants Workers Slaves Specialists Merchants Clergy Aristocracy Civil servants Soldiers From the very beginning the game presents only part of the strata. The rest get available as technology evolves. Strata parameters Values are the views of a strata on the best government policy. Openness is the level of difficulty in entering and leaving the strata. The degree of attractiveness is an indicator that reflects the extent to which people seek to change their social and professional status and become part of this strata. In working strata (peasants, workers, specialists) attractiveness depends on the level of their income and unemployment in the industry where they work. The attractiveness of civil servants depends on the state demand for them. The attraction of slaves always equals 25%. The attractiveness of the other strata depends only on income. The minimum attractiveness is 10%, the maximum is 500%. In addition, the attractiveness of a strata is influenced by its rights, consumption level, entry into the elite and dominant values in the society. Size - the growth of the size of a strata depends on natural population growth and the entry/leaving of people to other strata. In addition, the size of a strata can change the losses in the war and during repressions. Fertility falls with the increase of consciousness of the population and when achieving a high standard of living. It is growing with the development of healthcare. Mortality falls when the population's living standards rise, as well as with the development of healthcare. Consumption level reflects the categories of goods that strata needs. These products are divided into three categories: necessities, everyday and luxury items. If a resident has no money for essential goods, or if these goods are not on the market, he is threatened with death.The level of happiness depends on the satisfaction of everyday needs, as well as on the consumption of luxury goods. The ability to buy luxury items is a factor of transition to more attractive strata, while lack of access to essential goods and luxuries contributes to the transition to less prestigious strata. Income depends on the wage rate, or on income from enterprises. Expenditure is expenditure on consumption, as well as contributions to the funds of the factions. Wealth is all the accumulated property of a strata. Wealth increases due to the fact that strata keep part of their income. Wealth decreases with high crime level in the settlement or its looting, growing in the course of accumulation and investment activity. Unemployment exists only in working strata. Crime is the proportion of strata involved into criminal activity. Consciousness is the level of political culture and simply civic consciousness of the population. The loyalty to the authorities reflects the level of support or opposition to the ruling regime. It can take values from -5 to + 5. Civil, political and social rights are set by political decisions. Literacy reflects the level of theoretical knowledge of strata in its professional sphere and the degree of its qualification. Culture stands for belonging of a strata to a certain culture. Religion is belonging of a strata to a certain religion. Migration of the population Migration occurs between settlements if they are connected by roads. People will migrate between the settlements of the region, from one region to another, if there is a shortage of working force, the prestige of the settlement and the living standards of the population are higher etc. The quality of the road network determines the volumes of migratory flows. Factions In addition to strata, the game includes factions (groups of interests) that represent the force that can influence the political situation in the country. Examples of factions: Ruling Dynasty/Royal Court/Government Aristocratic/Oligarchic/Mafia clans Parties/Revolutionary groups/Separatists/Terrorists/Ideological groups Religious orders/Sects/Schools of Great people Metropolitan and Regional Elite Faction parameters Size stands for the number of supporters of the faction. Goals/values are goals and/or values that determine the direction and nature of the faction's activities. Openness is the level of difficulty of entering the faction. Prestige reflects the attractiveness of the faction among the other factions, as well as the degree of influence. Wealth is a foundation which deductions are made into by members of the faction and other factions/organizations. Income/Expenses Radicalism is readiness of the faction to illegal actions. Rights stand for the level of political rights of the faction. Cohesion is the level of strength of the faction and the ability of its members to act as a whole. Breadth of views consists in the hope of increasing the number of its supporters. The faction can expand the scope of its value views, but this makes it lose cohesion and weight of each faction member in its cumulative effect. 11. Culture and religion Culture is ethnic affiliation of the peoples inhabiting the country. It is based on a combination of 4 pairs of framework principles: Time-Space Individual-Mass Rational-Transcendental Spiritual – Material The combination of these principles allows to create 16 unique civilizations. Civilizations are not a homogeneous mass, but a collection of many heterogeneous cultures whose values are conditioned by civilizational principles. Cultural values, in fact, represent the imposition of civilization principles on each other. All in all in this way each civilization can form up to 220 unique cultures (i.e. in total in the game there can be up to 3520 unique cultures and 16 civilizations). The civilizational principles also define the peculiarities of religions of certain civilizations. Cultural assimilation The player is allowed to carry out cultural assimilation of villages and cities into the state culture at the cost of reducing control over them. The process of cultural assimilation takes dozens of turns. Players can also change their state culture. This process takes several turns. In the course of changing the state culture, control over those villages and cities that have a former state culture falls sharply. Religion If the value aspect of religions depends on the place of their origin, their organizational type is determined by the player. Religions have three parameters: 1. Type of religion: Polytheism Henotheism Dualism Monotheism Ethical system Secular philosophy Animism 2. Organizational structure: Lack of structure Decentralization Centralization 3. Type of organization: Cult Church Each of the religions has a certain level of influence, which depends on the development of religious areas where this religion prevails. 12. Economy Types of economic processes include hunting, fishing, cattle breeding, agriculture, extraction of raw materials, commodity production, slavery. Hunting - with the help of hunting the tile gets a certain amount of vegetables, fruits, meat and cattle from all the unprocessed subtiles. Fishing is carried out in river locations, as well as in water coastal locations. Similarly, the hunting region gets some amount of fish and pearls. Cattle breeding is a more productive type of activity. The area of pasture lands is important for cattle breeding. It depends on the type of landscape, the type of buildings and the level of woodiness of the tile. Pastures as source of improvement of locations increase the effective area of pasture lands. The lack of grazing lands leads to a decrease in the number of cattle in the region. Agriculture is the most massive type of economic activity in the game. It includes the largest number of working hands. Grain is both a product of agriculture and a necessary condition for its maintenance. Grain is distributed to locations from the region's reserves. The amount of grain that will be used for sowing depends on two things: Arable land area; Number of working hands and intensification of agriculture. Livestock, as well as improved instruments of labour, can increase productivity. Types of property: Property of a strata Property of a faction Communal property Regional property (owned by the regional elite) State Property Among the strata and factions holders can be small, medium or large. Each of the types of property has a certain entrepreneurial potential. So, the entrepreneurial potential of the community is lower than that of small holders. On the other hand, the community is extremely effective in difficult conditions of management. Dividing the economy into white and shadow Goods have a certain level of utility for the population Inflation = money supply * speed of money circulation = level of prices * production volume Trade Trade in the game is divided into internal, external and distant. Internal trade is carried out in the territory of one country between all the settlements having trade routes with each other. External trade is carried out between all the regions of one trade center. Long-distance trade is carried out between two connected trade routes by trade centers. A trade route is a regular land and/or sea path connecting two settlements with each other and the regional capital with the army it supplies. If a trade route is overloaded, first of all it is used for delivery of the most profitable goods. To plunder the trade route one only needs to put an army on it, whereas two mechanics are provided for protection: Allocate funds for the protection of trade lines (then in case the allocated funds surpass the force of bandits, the attacks are considered to be beaten and the squad of bandits bears losses); Place armies at unprotected areas (the area of protection can be selected by moving the slider in the army menu. The larger the area is, the more dispersed the army is along the route and the weaker it is in protection). Pricing The price of the goods is determined basing on the cost of production + costs of implementation + mark-up. The mark-up is determined automatically based on the maximization of profit, competition and price constraints. Resources Resources include raw materials or goods necessary for the production of another resource or satisfaction of the needs of the population or the army, maintenance of buildings or spending on certain actions. Types of resources 1. Food: Meat, fish, grain, vegetables, fruits, canned food, alcohol 2. Agricultural: Agricultural resources, cattle (cattle, pack animals), technical crops 3. Industrial: Construction materials, wood, leather, fibre, fabrics, paper, tools, weapons, luxury, consumer goods, machinery, electronics, prom goods, energy, ships, cars, airplanes, trains, fuel, consumer products, medicines, chemicals, plastics, local products 4. Strategic: Metals (copper, tin, iron, aluminum), energy (coal, oil, gas, uranium), sulfur, gold, silver, precious stones 5. Services, Slaves Resource characteristics Quality is the quality of the resource, depending on the technologies used for its production. It affects the cost and mark-up. Price is the amount of gold per unit of the resource. It depends on the value of demand and the value of the supply of the resource, as well as its production cost. Production is the number of units of the resource produced. Consumption is the number of consumed units of the resource. The principle of movement of resources in the course of trading can be given on the example of grain: - Peasants produce a certain amount of grain and then either pay a natural tax, or sell it in the local market, and then pay the tax in monetary terms. The remaining volume of grain is used as food, for new sowing and, if there are surpluses, for sale in the local market. - The tax paid by the peasants passes to the ownership of the country or regional elite. - Regional elites either pass a part of the received tax to the state, or leave all to themselves, depending on the established order. Available resources can be both sold and spent on their own regional needs. - Finally, merchants who buy a resource in the local market sell it at a shopping centre which the region belongs to, or in the capital of a region of one state at a more attractive price. 13. Science The technologies in the game have three levels: The first level of technology represents the general level of development of one or another sphere: agricultural, industrial, military or social. The second level of technology includes specific technologies, the condition for the invention of which is, among other, a certain level of technologies of the first type. The third level of technology is technological packages that group second-level technologies. It is technological packages that set the effect for different systems in the game. Technology implementation Implementation of technologies is carried out by means of investment by the state or population of money resources and administrative resource into introduction of a technology. The bigger an industry in which a certain technology is implemented is and the less well-known countries and regions of the country with this implemented technology exist, the more expensive the implementation is. Technology Exchange Countries active in trade are increasing the chance of implementing the technologies that had been introduced by the trading partner. 14. Military action The main resource of the army are recruits. The number of recruits reflects the number of people who the authorities are able to transfer to military service. The number of recruits is slowly increasing over time, but is quickly exhausted in intense military conflicts. Officers Officers are a separate category in the army. They are recruited as part of recruiting, but the ability to occupy this position can be closed for some of the countries. Army and control zones Army is a group of troops under a single command with its control zone. A control zone is divided into a response zone and a combat zone. As a rule, the response zone has a radius of 4 tiles. When an alien army enters it, it activates the line of behavior set by the player. The combat zone is an area of 1-cell radius. When an alien army enters it, it stops its movement and forces the player to enter the battle. Moreover, with the growth of military technologies and, consequently, the scale of wars, the control zone can increase significantly. Thus, the zone of control in positional warfare, typical of world wars, can reach the size of the region. Supply and replenishment of the army Each army must be assigned to one or more regions. The designated regions will continue to supply this army. Replenishment of the army reserves is carried out through a trade route of supply from the region to which the army is assigned. Roads can contribute significantly to accelerating the supply of armed forces. In addition, it is possible to replenish stocks by plundering the local population. The fighting efficiency of the army, left without supplies, sharply falls, while the speed of movement decreases and action points are reduced. It also means that in order to win over a strong army it is not necessary to win it in an open battle - it is enough to cut the lines of supply communication. Replenishment of the army is also carried out through trade routes of supply, which in addition to supplies (food, weapons, pack animals) will transfer new recruits. Reinforcements It is possible for armies to establish automatic reinforcements for other armies of the player located on its territory or in the zone of another army’s control. Movements, military operations and tactical schemes At the beginning of the turn each army has a certain number of action points (AP), which can be spent on a movement, the beginning of the battle, siege or change of the state of the army. The AP cost of the movement depends on the area and infrastructure development. Speed of the army equals the speed of the slowest kind of troops in it. The army can have four states: Combat readiness is a standard condition that does not give any certain bonuses; Marsh allows the army to move twice as fast, but twice as low as the protection characteristics. However, it is possible to attack another army during the marsh; Camp is a recommended condition for peace time. It allows not to spend a lot of supplies on the army, but it is particularly vulnerable in this state as both the characteristics of attack and protection decrease. You need to spend all the AP to move into another state; Ambush gives the army a chance to escape from the enemy’s visibility distance, increasing the characteristics of the attack, but reducing the protection characteristics in case of ambush exposure. The army can adapt up to three different tactical circuits. Tactical schemes increase the combat characteristics of some troops, but can reduce the combat characteristics of others. Or they can amplify some combat characteristics, but reduce the others. For example, the tactical scheme "phalanx" increases the close-in attack for spearmen in general and against cavalry in particular, but it decreases the speed of movement and its ability to maneuver. Therefore, in such a tactical scheme additional attention should be paid to the saturation of their army with cavalry. A tactical scheme is also a familiar pattern in the fight, the way of thinking for the generals, so change of an accepted tactical scheme can be quite painful: it leads to a loss of experience for the entire army. Battles between armies in the open field At the end of the turn for the enemy armies, which came together at a normal location (without a fortress or city), the battle is calculated. The battle consists of two phases. The "Long-range combat" phase. It involves all the troops capable of a long-range attack. The "Close-in combat" phase. All the troops are involved in it. Only a limited number of troops can participate directly in the battle. Their number depends on the technology and the area. The rest of the troops are in the standby mode. For example, in the mountains it is quite possible to stop quite a large army. The formal winner of the battle is the one who leaves the battlefield. However, the gained experience and state of the army after the battle play a larger role. Siege of cities and fortresses. City fights It is impossible to take a fortress or a fortified capital without siege-assault engines. Also taking a fortress or fortified capital always requires a minimum of 2 turns. In the first stage of assault it is necessary to break the fortifications and enter the besieged settlement. The battle at this stage consists of two phases. The "Long-range assault" phase. It involves all the troops capable of a long-range attack and siege-assault engines of the attacker. The "Close-in assault" phase. The purpose of this phase for the attackers is to capture the wall of the settlement, and for the defenders-trivia attack. If the attacker managed to capture the walls, the next turns begins with the battle for the settlement by the rules of the battle in the open field. However, for the final victory the attackers must destroy all the troops of the defenders, and not just win. Only then the settlement will be completely seized. Thus, battles for cities, which consist of more than one location, can last during more than 3 turns, as each part of the city will have to be captured separately. Fleet Fleet is a group of ships under the authority of a single commander with its control zone. As a rule, the zone of control is an area with a radius of 3-6 locations. When the alien fleet enters it, it leads to the sea battle. The radius of the control zone increases with the growth of technologies and experience of the fleet crew. Fleet Supply and Repair Unlike the army, the fleet is not assigned to any region and is supplied by all of them. To exit the port, the fleet can bring a limited amount of supplies. Supplies include food, weapons and building materials. For replenishment of supplies it is possible to go to any friendly port. The fleet, left without supplies, sharply loses fighting efficiency while the speed of swimming decreases and action points get reduced. During the battle ships can get damaged or lose a part of the team - to repair and replenish the team again you have to go to a friendly port. Swimming and sea battles The fleet receives a number of action points (AP), which can be spent on swimming, repair and replenishment of supplies, boarding and landing of the army and the beginning of sea battles. The sea battle is not divided into phases and represents individual battles between ships of fleets. The formal winner is the one who retained the highest morale of the fleet.
  19. Hello! I'm currently developing a top-down RPG styled game with an Entity Component System architecture and, as the game grows in features, so does my game entities, that is, item models, enemy prototypes, etc. Those definitions are currently in JSON files but at the end of the day I still have long factory classes that read from those files and populate the entities with their respective components and properties in the most naive way. Reading through a presentation about Techniques and Strategies for Data-driven design in Game Development (slides 80–93) (warning: big pdf file) there is this "prototyping approach" where you can build up each game entity from multiple prototypes. I find this really interesting, however, the presentation doesn't mention any implementation details and I'm totally in the dark. I don't know how powerful should this system be. By the way, I'm using Java and LibGDX's engine. My first idea is making a robust prototype-instancing factory where, given a JSON file, it will be able to return an entity populated with its corresponding components. For example: Enemies.json { "skeleton" : { "id" : 0, "components" : { "HealthComponent" : { "totalHealth" : 100 }, "TextureComponent" : { "pathToTexture" : "assets/skeleton.png" } } } } If I wanted to instantiate a Skeleton entity, I would read it's prototype, iterate over it's components and somehow I would instantiate them correctly. With this approach I have the following issues: It will most likely involve using Java Reflection to instance entities from a JSON file. This is a topic that I know little about and will probably end up in dark magic code. Some instances properties can't be prototyped and will have to be passed as parameters to the factory. For example, when creating an enemy entity, an (x, y) position will have to be provided. Suddenly creating instances is not so straight forward. How powerful should this system be? Should it have this "recursive" behavior where you can extend a prototype with an other and so on? This sounds a little bit like dependency injection. Am I reinventing the wheel? Is there anything done already I can make us of? Even though it's still in it's infancy, here is a short demo (under one minute) of my game. Thank you!
  20. RidiculousName

    FXML and CSS in JavaFX

    Would any readers please explain to me the differences between FXML and CSS? I just want to create a basic GUI in JavaFX. For example does one work better on linux? Is one easier to learn than the other? What are their benefits and drawbacks?
  21. Hello, I have problems deciding some design questions. About the game: It's like Anno 1404 but multiplayer only 1) Accessing GUI directly (Object interaction) Should the Notifier has some kind of queue or should I call it directly, because the player expects immediate response. A queue would maybe overkill in things of performance, if it's processor has its loop in the render method/loop. As of writing these lines I doesn't even know why I would have even considert choosing a queue. Searching for a solution to my problems, I came across this article http://gameprogrammingpatterns.com/event-queue.html and it made me thought if it is a good practice or needed for my problems how to wire objects and handle asynchronous tasks and object communication. I don't know, if its a good idea/programming style to let the ActionController do everything as a central station or to let objects do their own eventchain, like trigger a request from the ActionController, the RequestBuilder sends its request directly to the NetworkManager and the NetworkManager can directly call on the GUI. 2) Observe game objects From time to time the client sends a request (carrying the actions done by the player) to the server to get a new update of the gamestate and if the actions are allowed and possible. The server calculates end send back the "cleaned" gamestate. The client receives the approved gamestate from the server and transition/interpolate from it's current state to the ones of the server, like undo not allowed actions with a message in the players notification feed, what was reverted. (not the ones shown in the image above, but an extra one) So there is one observer to observe the overall gamestate and little ones that observe game objects like buildings on the grid, that produce items. Is it good to use a observer pattern here? Can't say why, but my intuition says: Observers for states the player doesn't initiate directly (burning fuel, producing units over time, ...) Listeners for direct actions the player does (pressing a button to login, build a building, move a item on the map, pay for something, trade) A better example: The player wants to research "Ironswords". So he presses the button for this research. The listener notice the event and creates an observer (or subscribe that event to an existing research-observer) which observes the progress over time. If the research is finished after a certain amount of time, a notification is added to the players feed and the event unsubscribes from the observer or the observer is getting killed.
  22. LukasIrzl

    Tales of Vastor - Progress #9

    Tales of Vastor - Progress #9 Content What's done? What's next? Music What's done? Black knight model Another enemy was added to the game - the black knight, one of the late game enemies. Waypoint icons The waypoint icons will help you identify what is waiting on a certain waypoint. Currently, the following ones are designed and configured: The boss icon will be displayed on waypoints, where a boss will occur. So, you might want to buy a few items before getting into the fight. The merchant is located near Udins castle. There, you should stock up a few potions or even buy a new weapon. Last but no least, the temple icon. It displays a temple, where you can save the game and heal all your characters. Status icons Up until now, there was no way to know, which status effects applied to a certain character. Later, the following icons will be displayed, depending on the active statuses. A short explanation to the effects: freeze: Does not allow action choosing for a certain amount or turns. The only good thing about the freeze effect is, that it nullifies the fire effect. fire: Damages the affected character at the start of each turn. If you can not remove the status fast enough, the character might end up dying. If the character is frozen, the fire effect will remove the freeze status. defense up: Raises the defense of the affected character. This status effect is essential to survive certain bosses or even harder fights. lower defense: Will decrease the affected characters defense. You should be careful, if a character has this status applied, because the damage received will increase. New background Here is one of the refactored backgrounds used for fights: This one provides more fog in the background, which shows the depth of the landscape. Lately, I love to put in a little bit of fog to the backgrounds, since it provides so much more life. What's next? This week, I want to focus on the character animations for the playable characters. Up until now, the base animations are already available for every character. Power attack animations, on the other hand, are still missing. They should be complete, as soon as the beta version is released. Alongside with the new animations, a few particle effects have to the created, such as lightnings, status changes and many others. Music I am glad to tell, that the main theme is already composed and others will come soon. Here is the main theme by Andrew LiVecchi: If you missed to check him out on YouTube, be sure to click the link: Youtube.com If you have feedback, you can contact me via mail or direct message whenever you want. Be sure to take a look at Twitter as well, since there will be more frequent updates. Thank you!
  23. I'm sure many of you know Eric Lippert's Blog series: Wizards and Warriors. In it, he has two rules: A warrior can only use a sword. A wizard can only use a staff. Over the series of blogs, he tries to show you how the C# type system fails to implement those rules and what to do about it instead. He suggest the creation of a Rule class, and let the Rule system determine what can happen in the game. You can agree or disagree, that's not the point of my question. I included it because it relates to my bigger question, how would you tell the Rule class or system that the object you're trying to carry is in fact a Sword without instanceof? For my question, lets remove the Rule object and stick with two objects, a Wizard and Sword. A Wizard is a subclass of the abstract Character class and Sword is a subclass of the abstract Weapon class. The Character class will have a method called tryAdd(); public final boolean tryAdd(Weapon weapon){ // Code to add Weapon } At first I thought I would use an enum to determine what object the player is attempting to add to it's inventory. public enum WeaponType { ReloadableWeapon // -- imagine more weapon types } public abstract class Weapon { private WeaponType wt; public Weapon(WeaponType wt) { this.wt = wt; } } public ReloadableWeapon extends Weapon{ public ReloadableWeapon() super(WeaponType.ReloadableWeapon); { } } As pointed out, it violates DRY and is a poor version of instanceof. Okay, fine, the comments suggested a Map or Collection of attributes, even this GameDev link suggested the same thing. So a long the lines of this: public enum GameObjectAttributes{ Replenishable Destructable Health LongBlade ShortBlade Mana Health Potion Indestructible } public abstract class Weapon { private List<GameObjectAttributes> gOAttributes; // imagine a constructor :D. public final boolean containsAttribute(GameObjectAttributes attribute) { // determine if weapon contains a specific attribute. } } Suppose I had a Sword object, and the level of detail allows a Sword to be damaged and broken if hit hard enough, so my Sword object might contain Destructable and LongBlade as attributes. As suggested in this link, this too is a bad idea because I'm using the attributes to determine or carry out behavior with that object. HOWEVER! Isn't this how OOP is supposed to work? I query an object for an answer, in this case true or false and carry out actions with that object? In this case I ask the Weapon, do you have LongBlade as an attribute? If so, the Wizard cannot add it to there inventory. The method doesn't add the weapon and returns false. Problem Even if we were to use a Rule class, at some point, we have to determine what object is being passed to the TryAdd() method, in other words, one object will have to communicate with another object to determine the object type. The link that suggests the attribute collection is a bad idea, says that a Player should implement a tryCarry method, but even that methods needs to decided if the Weapon parameter is a Sword. How then do you make that distinction without instanceof or a variable to decided what to do? Or How do two objects communicate with each other so that one object is aware of the other object type without violating OOP principals? Can someone provide a clean code sample? This problem is getting frustrating to solve because no matter what solution I come up with, someone will point out it's a bad idea, but no one can provide a solid solution to the problem. Even Eric Lippert's blog just suggests a Rule class but no example code of how to implement it. What seems like a simple solution to a problem is ripped apart by veteran developers who are quick to point out something is a code smell or bad code. Sometimes I wonder why bother writing any code at all.
  24. Introducing Jumpaï! A game made using LibGDX. It's been 21 months the game is in development and we just released version 0.3! It's an online game, there's a server running at http://jumpai.net/ and everyone can join! Registering is easy, username password and you are good.The point of the game is to make your own level! There's an easy to use, integrated editor allow you to make your levels and they same automatically on the cloud. You can then join them online to play with your friends. A lot of cool mechanics, portals, powerups, items... Check it out! Trailer: Also, you can join us on discord https://discord.gg/R4ZafEw Screenshots:
  25. thecheeselover

    Unit Vision

    Subscribe to our subreddit to get all the updates from the team! First off, here's a video that shows the unit vision in action : So, what is the unit vision? It's a simple mechanism that notifies a unit when another unit enters its vision field. It also takes into account if the vision is blocked by entities. This is how it is implemented step by step : A cone ghost control is attached to the unit's head All units intersecting with the cone's AABB fire events (AABB because of how Bullet Physics work) Cast a ray towards the visible unit and then adjust the angle so that it fits in the cone If the ray cast touches the supposedly visible unit, then it is truly visible Using the debug view of Bullet Physics in the jMonkey Engine 3.1, we're able to see what the vision cone actually looks like. And when inside the cone we can't see it because of culling. However, we can see the enemy's arm moving, which is a test I did for when a unit see another unit. Behind a box, the enemy does not move its arm because he can't see me. But when I leave my hiding spot, he can see me again.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!