• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

461 Neutral

About Dawoodoz

  • Rank
    Advanced Member

Personal Information

  1. It seems like Java is leaking because it creates an intermediate image for interpolation so when I first draw to an image that I recycle myself using AlphaComposite.Src and drawRenderedImage, I can then use my custom composite in a 1:1 scale ratio without leaking memory. The wasted time is acceptable because the operation is only performed when the level is loaded.
  2. Is there a way to blend pixels directly to Raster in a BufferedImage with custom blending using own pixel loops instead of cloning the source pixels with getDataElements? I tried inheriting from Composite and CompositeContext but the permanent memory leak causes crashes when the memory runs out. I need custom blending for light effects so AlphaComposite is not enough for my project. In the worst case, I just make my own image type using arrays as I usually do in C.
  3. chmod +x ./compile.sh ./compile.sh cp ./MANIFEST.MF ./../output (cd ./../output; jar cfm Game.jar MANIFEST.MF * ./../source/resources/*.png chmod +x ./Game.jar java -jar Game.jar ./../source/media/ ) Thanks! Seems to work now after just adding the resource files in the jar command. :)   BufferedImage image = null; try { image = ImageIO.read(new File(this.externalMediaPath + fileName)); } catch(IOException e) { try { image = ImageIO.read(Class.class.getResourceAsStream("/source/resources/" + fileName)); } catch(IOException f) { f.printStackTrace(); System.out.println("Image not found at " + fileName + "!"); return -1; } } When the selected mod folder does not contain the image, it will now fall back on the built in resources. I should probably check if the files exist before trying to load from one location at a time but I can fix that later.
  4. University courses in AI teaches many methods to solve factory production problems so you can find it in most course books about AI. You might want to separate the AI into multiple systems doing their own things before you complicate it further. * Diplomacy (When to start a war) * Warfare (Who to attack when at war) * Resources (How to reach the number of wanted soldiers) Each state of a resource has a counter and a whole set of those make a world state. Rather than storing a list of hammers with different properties, you have a counter for each possible combination of properties that matters to the AI. NumberOfBrokenHammers, NumberOfNewHammers... Each action consumes or borrows resources/workers, takes a certain time to complete and produces resources/workers/buildings when completed. In each tick of the production schedule, calculate a number of possible scenarios with simplified game logic a few minutes into the future and use heuristics on the final results to estimate a score based on available resources. Remember the best solution for the next tick and refine it by consuming the time that passed and filling with new random guesses at the end. Each random guess may use as much as they want from the previously optimal plan but may only randomize the plan after the point of change since reuse of actions after a change makes no sense. Within a random walk, add random actions until no more actions can be added, step over time to let actions in the list be completed and return the investments. The generation of random actions should be constrained by a primitive reflex system that prevents doing things that can easily be proven to be suboptimal like not producing wood when the stockpile is full. This is inspired by the Monte Carlo method that is easy to implement as long as you keep things simple. https://en.wikipedia.org/wiki/Monte_Carlo_method
  5. Getting back into C++

    JetBrains CLion is an IDE for C++ that works directly on Linux and other systems. I use it at work and do not miss being limited to Windows. It has free student/hobby licenses but you have to renew them yearly and there is no express version. Since it builds on CMake, you can just keep programming with another editor if the free license runs out or if you just don't want to subscribe anymore. + Intuitive debugger. + Built in static analysis. - The settings are overly complex since it is still in development. - Editing text may feel weird until you configure it right.
  6. I have created a manifest file for my desktop Java game that is used to create a jar file automatically from my shell script and now I need to add resources into the jar file.  :) Is there a simple way to specify a folder in the manifest file without depending on additional tools? All guides point to the obvious way to just point and click in Netbeans but I want to know how the build process works so that I can fix things when they break using only the JDK tools. Shell script for building the jar: chmod +x ./compile.sh ./compile.sh cp ./manifest.txt ./../output (cd ./../output; jar cfm Game.jar manifest.txt * chmod +x ./Game.jar java -jar Game.jar ./../source/media/ )  I am currently giving the path of the media folder as a command line argument since it might be useful later for mods. The manifest only contains the main class name for now and I haven't figured out a good namespace for Main yet. Main-Class: Main
  7. I will just stick to Java then and live without userdefined value types. Regarding OpenGL, it is a work damage from having seen it malfunction hundreds of times in the real world. Lobotomy might cure me from what I have seen buggy OpenGL drivers do to correct code. My daytime job as a firmware developer for hardware producers is mostly to go around bugs in OpenGL drivers so I would prefer not to deal with that when I get home. Even if I would test my games on 20 different OpenGL drivers which is beyond my budget, the next driver version would still break anything slightly complex and require further maintenance. I guarantee you that all your OpenGL games are broken on some driver even if you manage to follow convention to 100%.
  8. Seamless map Integration

    You can optimize 3D graphics by dividing the world into one model per 20x20 meter tile. All static items in the same tile have their triangles merged into the tile model. This reduces the number of draw calls when you have thousands of low detailed static items. The tiles are also useful for distance culling by not drawing distant tiles. Do not try to shift the world coordinates according to the screen since it will make it hard to refer to places in the AI. Define one system for the world and write conversion functions between world and screen space. If something changes in the tile model, delete it and show the separate instances to trade render speed for rebuild speed until changes are done and a new model has been generated for the tile. This system can allow fluent high resolution voxel carving in .NET when compressing the voxels in each tile using axis aligned integer boxes. If using sprites in 2D, the same can be done with multiple layers of image buffers or depth buffers in each tile. When a static sprite changes, redraw the affected tile images. If adding sprites on top, just keep drawing on the tiles.
  9. SDL2 and Box2D Nothing Shows Up

    I would try to assert that the ground is where it is expected to be by visualizing and making ray intersections. If you can make primitive line drawing of the physical world for debugging then it can help a lot when figuring these things out. A lot of physics engines provide some kind of line drawing callback to visualize with any graphics engine.
  10. SDL2 and Box2D Nothing Shows Up

    Maybe your should start with SDL and get some basic movement working before using a physics engine. Using a physics engine require lots of understanding in order to integrate the game logic in a fluent way so trying to make your own physics first will give you a better understanding of what the engine does by stepping in a debugger or even calculating examples on paper. Reading about euler forward and midpoint is a good start. I do not see any code for either dynamic timestep nor interpolated fixed timesteps. You can make a button that slows everything down with a delay or heavy calculation to see what happens when your game scales up or someone plays it on a slower computer. The easy way is to run the physics 300 steps per second and run as many as required for the time spent rendering one frame and save the remainder time accumulated for the next frame. All physics and game logic can then run the same way independent of rendering speed. Everything that is just visual and can be directly derived from the world state (animations, GUI,...) should be updated as needed before rendering to avoid getting more fixed amount of workload than the computer can handle.
  11. I agree with pong being simplest. After that, it can be extended to a block busting game.   Javas built in 2D graphics can be used for retro strategy games and has no hassle with linking or cross compiling. The libraries that are native to a language usually have a longer lifetime before it has to be ported or maintained. I can still play the games that I made for Windows 3.1 because I only used the default components in Visual Basic. Newer games with advanced stuff did not survive from Windows2K to XP or Windows7 to 8 before I had to fix new bugs. It sounds a bit boring but the first games made is like the first drawings that you will want to play 50 years later.
  12. Is there any reason to use SDL2?

    Arguably is a key word in that sentence.  Arguably, libSDL2 is easier to use, so you qualify for only a vague response on that. libSDL2 is still useful, because it's widely used, well known, has plenty of tutorials and example code, and it works well.  It's easily available on all popular desktop platforms, mobile devices, and consoles (which is certainly not true of GLFW and SFML) including modern display servers on Linux (also not true of GLFW and SFML, and they have no plans to port to Wayland or Mir), and supports GL and GL|ES contexts and Vulkan is in the pipe.  libSDL2 is also actively maintained full time by its original developers and is a commercial product with corporate backing, not a hobby project at the whim of some individuals' spare time. libSDL2 does not need to hijack main.  On Microsoft Windows a wrapper for main() is provided as a convenience since neither WinMain() nor _tmain() are portable or standard, but there's nothing from stopping you from implementing the necessary stuff in your own Windows-specific main() code if portability is not your concern.     Well, that's a property of your Linux distribution.  I work with libSDL2 all the time (on Ubuntu), and members of my team are regular upstream contributors so I test their work, and I have never had difficulty installing it or crashes related to dependencies.  I would not use a broken Linux package management system as a criticism of an upstream package.     The player who buys a game for Linux does not care whos fault it is, the game will be blamed if it does not go around the bugs in the system. It either works from the start or leads to a refund.
  13. I don't need a huge pile of fancy features that I can easily write myself. I just need something minimal that works for retro graphics. I am prepared to use some kind of OpenCL wrapper from Java or write my own software 3D renderer from scratch in C++14 to get rid of as many bad dependencies as possible. Both SDL and SFML may randomly crash during install because of broken dependencies on Ubuntu. I cannot expect the end user to compile dependencies from source or fix broken OpenGL drivers in Linux which is the current praxis for Linux installations. I do not trust OpenGL nor anything built on top of OpenGL because it is not a real standard when there is no driver certification. Vulkan is not ready yet as the drivers are few and buggy.   Is there any other platform than Java that has decent performance and can be installed easily on Linux?
  14. Is there any reason to use SDL2?

    SDL2 is for those that otherwise would write their own window frameworks just to lower the overhead. It does not do much abstraction since many things behave differently on different computers. The only thing I really dislike about SDL2 is the broken Linux installation system that will always crash with dependency problems if you installed any program before SDL and that is something that end users who dont know programming has to live with.
  15. Last time I developed something on Windows, I got screwed by a hidden c++ dependency (MFC activeX) that could only be compiled on visual studio professional that I was trying for free as a student. Then Windows 10 came with built in spyware and tried to replace my installation of Windows 7 against my will with a UI nightmare. Now Microsoft has fired lots of people that used to fix their bugs so the system will slowly become more unsafe and unstable. I cannot develop another product that is tied up to a system that microsoft has on life support and spies on the users.   Now I try to develop games on Linux which means that OpenGL is a new dialect on each computer even if they have the same linux distro. I tried Vulkan but it was too verbose and everything was specialized for certain GPU models. I am desperate enough to write a software rasterizer since OpenGL cannot even draw a quad straight without weird half pixel offsets that depend on how broken the drivers are. I have not played any game since I abandoned Windows since all the linux games on GoG have broken installations with missing dependencies.
  • Advertisement