Advertisement 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


Categories

  • 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

Categories

  • Audio
  • Visual Arts
  • Programming
  • Writing

Categories

  • Game Dev Loadout
  • Game Dev Unchained

Categories

  • 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

Forums

  • 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
  • Unreal Engine Users's Unreal Engine Group Forum

Calendars

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

Blogs

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

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


About Me


Website


Role


Twitter


Github


Twitch


Steam

Found 138 results

  1. Hello! I'm brand new to these forums, and I am looking for a hobbyist artist to work with me on a game I have a working prototype and documentation for. The game is in Java, and it is a Roguelite game that allows the player to select a class that has unique abilities before facing the procedurally generated dungeon before them. I do have plans for the future of the game in later stages of development, but will omit those unless interested, as I want the artist who's working on this project with me to have a good amount of creative control. If you are interested, email me at jlars789@gmail.com, where I can link the Dropbox to the playable prototype demo and the documentation I have so far. Thanks in advance!
  2. Zemlaynin

    The Great Tribes Devblog #33

    Hello dears! And happy new year's holidays! It's been over a month since the last development diary. I have to say that I wanted to post a diary before, but faced with a intractable problem, which spent a lot of time. But all in order. According to the development plan, the first contact with AI was implemented: At the bottom of the screenshot you can see messages about crossing the army control zones with another army and the city. Now we had to develop an interface element that would display the event data: This screenshot in the upper left corner shows the implementation of UILabel with the ability to transfer text by words. An important element of the interface that is useful in the future. In the lower right corner, above the end of the course is now visible various messages, hover the mouse over them POPs up a hint (also a new interface element), with a short description of the event. By pressing the right button, the event can be closed without making any decision, and the left button can open the message. In this case, when you click on the event button will be the first diplomatic contact in the game: It was further implemented the first maneuvers of AI. AI walks on the map and tries to determine the boundaries of its continent. In the video at Dukat https://youtu.be/69G51u_Mq3g?t=693 that is the moment where he runs over the enemy army, which pays no attention to him, because busy with study card And somewhere in this place and at this time, I was faced with a problem, a performance problem. Our Modeler has a powerful modern computer of red Assembly. But it the game is terribly slow shipping a single core processor. The reason is simple-there are a lot of cores in new processors, but in fact they are less productive in single-threaded applications. And that moment I had a render in one stream. But in fact, the reason was not so much in this. And in the process of finding problems, I decided to count how many polygons we have in the scene: On the middle map at the maximum distance and a large cluster of palm trees - it's just scary! 15 824 756 triangles! Almost 16 million!!! After a bit of map generation, I found a place with 16.75 million. Although here is a similar place with trees gave only 8.5 million triangles: And in the middle stage consisted of about 4 million: In General, I was glad that my render copes with such a huge number of triangles, but their number was excessive. It was necessary to optimize the number of polygons in the models. 40% decreased Poligona trees! Differences practically are not visible. Next, we have altered palms - Poligona on the palms was reduced in 10 times. 600 - 700 against six thousand of polygons per pack. While there was parallel work on the models I have been trying to simplify the geometry of terrain. Here's what it looked like before optimization: And after the first steps: But it was all done by a simple method — all smooth tiles were replaced by two triangles instead of 882. But there were still flat places that could be optimized, and I began to build polygons from those triangles that had the same height: Build on them convex-concave contour (Concave Hull). With Convex Hull ω was not a problem, I already used the Graham scan (Graham scan). But the construction of Concave Hull has a problem... Information on this topic on the Internet was quite difficult to find. I had to write the implementation of algorithms from scratch. I will not lie if I say that I read a dozen different dissertations on this topic. But all the proposed algorithms gave an approximate result with some error. After a week of torment and pain, I came up with the idea of my algorithm, maybe I'll describe it someday As a result of two weeks of torment, I got the desired result and was able to build Concave Hull of almost any complexity, bypassing the set with holes, just dividing them into 2 halves of the hole. Received contour and triangulated it: Getting the output of such a result: The fog of war has also been simplified: And in zones where was present only fog of war it turned out only about 300 polygons: But in the end I was upset with the result and tell you that these two weeks I spent in the shuffle... The algorithm developed by me gave a significant increase in performance when rendering, as the number of polygons on average was reduced by 60 — 70%. But the generation of the map began to occur 10 times slower.... the algorithm was time-consuming and difficult. 3 days I lost in ATOM RPG removing stress:) Even at work did not go. Thank God we have at this time the thermometer went off scale at the border -44 - -46 degrees Celsius. And I gave my melancholy for an excuse not to start the car. And before the new year holidays, enough to play, but the truth is not passed the game, I gave a new lightweight version of the algorithm, which was suitable only for my conditions of tiles. Data calculations for optimization were not noticeable against the background of map generation and the number of polygons decreased by an average of 40-50%. But there are artifacts when rendering water, I had to rewrite all the algorithms associated with water. Here is the result: Anatoly meanwhile made unit of nomads: While he lies resting While working on optimization, I came up with the idea of how to change our mountains. Mountains have become more embossed, it is noticeable without texture, as the texture is now not suitable for them: On the grid, so in General the differences are obvious: It remains the case for small — need a new texture of the mountains. The next step was to rewrite the resource loader and map generator. Along the way, remaking the start menu for all these things: Now loading of resources goes in parallel and then map generation begins. I did a great job in dividing the render into 3 streams. The whole difficulty was in synchronization. Now we have one thread responsible only for drawing, the second thread for recalculation of the visible space when moving the camera and other interactions with the map space, and the third thread is responsible for animation and communication with the server part. And Yes, we now have a server part responsible for all events in the game and for the AI. In turn, each AI player is a separate process. Let's summarize the work done: - Graphics optimization from the software side. - Optimization of graphics models. - Server part. - Split render into 3 streams. - Preload resources (textures and models). - Rewrote the fog of war, water and terrane shaders. - Reduced RAM consumption by 20-30% - Implemented a number of UI elements - Redesigned start screen with the new UI. - Fixed errors in normal calculations. - Fixed the hills. - New mountain. - Introduced normalmap for terrain. - New selection of units. - New animation units. - Window of diplomacy. - Actions AI. Study the map. - Actions AI. Diplomatic contact. - Actions AI. The conclusion of peace, friendship, or a Declaration of war. - Actions AI. Action units in a collision. - In General, a lot of work has been done to optimize and not a lot of game mechanics. I hope this month to the CE goes to plan and I'm finally going to finish the city Thank you for your attention!
  3. Hello everyone, I need some help with my Java text-based dungeon crawler. My issue is that i want to spawn a monster with random specs every time a player enters a new room, pending an encounter roll. I am trying to figure out the best way to do this, logic wise. Should I (can I) just recreate the same object each time like, Monster monster=new Monster(); and have the class constructor use random number modifiers to construct the object each time. Is there a way to destroy the object so I can remake it with the same variable name? Any help is appreciated here. Thanks
  4. I have a class with a bunch of private methods used to determine class attributes. These methods rely on other class attributes to determine the values they return. I was wondering if it is seen as more proper/elegant to pass in attributes as arguments or just call `this.attributeName` whenever I need to reference them.
  5. Before I select a method for saving my my large 2d rpgs map maps full of custom objects (Fighters, Books Potions, Wands, Armor, Buffs, Weapons, Scroll, NPCs, Buildings ECT.) that is too slow or won't meet my needs. I want to know what would be the best way or least a good way. I want to have maps of at least 500*500 32*32 tiles. I'm using the TiledMap libGDX class for the map but the objects are all my own using many abstract classes and the KPCOFGS(Kingdom Class Phylum Order Family Genus Species) method. I have gone with data driven editing as opposed to scripting so my classes have many editable fields to change various things about them. The fighter class has over 100 fields for things like various kinds of armor, the weapon , the packs, strength, strength increase, experience, Iq and many more). I have an editor written for these. They then get placed on the map and in lists stored in game objects class that Game Map has access to. My question is what would be the best way to save the map and all associated objects to load at a later date? I would like to able to save the maps on windows, mac and linux and load them on windows, mac, linux, and android.
  6. Hi, I'm doing some experimenting on network architecture and currently working on my multiplayer RPG game. The game is written in c# (of course) and the client\single player part has basic functionality, so now I've started working on the network side of stuff. I've heard about KryoNet(Java) and it seems like a good solution for my server. But as I'm fairly new with C#, I wasn't sure what is the best library to go along with it on the client side. There is no KryoNet-like library in C#, so I was wondering if you have any recommendation on a library you know, or should I just use the basic system.net of C# and try to learn from that. I would gladly accept any tips! Thank you!
  7. 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:
  8. Before starting: I'm looking for a Java developer who want to help me improving my game engine and then, create a game that I will describe My goal is to create a "fight arena" multiplayer game similar to xblaster (only how they managed arena, I do not want robot stuff) For people who do not know this game, let me explain how I'm inspired by it You log in the game, you can enter an arena at any time, in the arena, there are 4 portals where you can go and enter another arena, there can be a maximum of 4players in the same arena, they have to fight each other in order to get money to improve their characters. I won't describe it any longer, I've much more ideas about the game. I already done the server architecture, I have a Game Engine (the client side), but there are still things to do on it, that's why I'm looking for another developer to help me if the game also look interesting for you Here the version of the engine: https://github.com/TheMode911/ProneusEngineV2/blob/master/src/main/java/fr/proneus/engine/demo/DemoState.java Discord: TheMode#3487
  9. So I have a decent amount of JavaScript experience now and decided I was gonna lower my head and start cranking out some 2d games, partly to learn, partly to have fun. Afterall, HTML5 canvas is such an easy and enticing medium. I love the JavaScript implementation of it. But after literally struggling for a week to get basic game functionality working I have had enough of the little stupid bugs that pop up with JavaScript. Don't get me wrong, I still love the language for scripting. I'm just not going to spend 20 mins coding and 5 hours debugging just because the language is crap. I've decided to return to my previous endeavor, Java. I like Java a lot and the only reason I haven't pursued more in the way of game development is just for the fact that Java is limited to mobile or PC apps that may never see the light of day unless it's hosted on some obscure Java game hosting website that is populated with 2,000 half developed games that no one will ever care about. BUT, still, I enjoy hand coding and I know C# but don't feel like using Visual studio and I really don't wanna hand code C# on the .Net or whatever. I use Visual Studio for business apps (ASP.NET) but I don't wanna build a game with it. So, does anyone have any points to share about why moving to Java for game development is not smart? Besides the whole, "Java is slow" thing. I mean things that might make it harder in JAva to make games vs. in other languages. Please share your thoughts.
  10. 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?
  11. I recently transferred to a new college that teaches Java as part of it's Computer Science core classes. I've heard Java isn't that great when it comes to making games, and I was wondering what its weaknesses are compared to more popular game-creation languages, and if any of its weaknesses have a work-around of some sort. Specifically, I'm interested in Artificial Intelligence and Procedural Generation.
  12. 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:
  13. 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/
  14. 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
  15. 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...
  16. 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(); } }
  17. 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!
  18. 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"); } }
  19. 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); }
  20. 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?
  21. 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!
  22. 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.
  23. 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() { } }
  24. 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!!!
  25. 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)); } }
  • 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!