Giter VIP home page Giter VIP logo

akapkotel / python_real_time_strategy_game Goto Github PK

View Code? Open in Web Editor NEW
15.0 4.0 0.0 89.91 MB

This is an RTS-like game written in Python 3 with arcade library. This is my most ambitious project up to date, since I try to overcome Python's shortcomings and make as efficiently-running game as possible. It will cover pathfinding, UI, AI, and graphics, using relatively slow and inefficient language. Main goal is to make it running sufficiently fast for p1layers to be able to actually play the game without pain. I do not have any good idea for the name of the game, so, for now it is just an RTS.

License: Other

Python 99.98% Dockerfile 0.02%
rts-game arcade-library pathfinding efficiency sprites game-mode

python_real_time_strategy_game's Introduction

Real Time Strategy- a RTS game written in Python

INTRODUCTION:

This is my ambitious struggle against Python inefficiencies. An RTS game made with Python 3.6 and Arcade 2.26 Library is my attempt to make something what should NOT be done with this language.

I've decided to use Arcade library because of useful SpriteLists concept and efficient way of drawing Sprites. All advantages and disadvantages of Arcade library are available here: Arcade performance

INSTALLATION AND RUN:

For now, you have to clone or download this repository. Then create new virtual environment, install requirements and run it by running game.py script in your IDE (e.g. PyCharm) or in terminal.

PLAYING:

To be done.

Menu

Game Mode Menu

Game

WHAT IS DONE:

  1. Window and Views as different 'states' of the game.
  2. Pathfinding with my A* implementation using PriorityQueue with my efficiency improvement: set of elements contained in PriorityQueue for faster lookups.
  3. Simple - map-nodes-based - collision avoidance (buggy!).
  4. Simple debugging logic.
  5. Pausing game logic.
  6. Finding files by their names without any paths-constants etc.
  7. Basic mouse-handling: selecting, unselecting, giving move-orders to Units.
  8. Scratch of the keyboard-handling.
  9. Efficient replacements for the arcade.Spritelists allowing me to arbitrary 'activate', 'deactivate' updating and drawing some Sprites to avoid updating and drawing objects which are not on the screen.
  10. Basic - distance and geometry-based - detection of which Sprites see each other.
  11. Alternative scheduling calls system to work with the (to be done) saving and loading game.
  12. Simple permanent group of units is now 'saved' and player can activate them with 0-9 keys press.
  13. Mouse-drag scrolling the map.
  14. Small improvement to efficiency by spreading of many pathfinding calls for several update-frames, so no big lag when sending units to the opposite corner of the map.
  15. Added queueing the pathfinding-requests, and a Pathfinder changed to the Singleton.
  16. Divided map to the Sectors to avoid visibility-tests between all Units and Buildings in game.
  17. Scratch of Menu and user interface systems.
  18. Units are now asking other units for pass if they are blocking their way.
  19. Pathfinder can now find paths leading to the encircled areas or with entrances blocked by units.
  20. Working sounds: music background tracks, sound-effects, ui-sound-effects.
  21. Display currently selected permanent units group number above each unit belonging to this group.
  22. Units are now 1x8 or 8x8 (tanks with turrets) sprite-sheets, so they can face 8 directions (and other 8 directions for turrets). Each Unit can be spawned in many, various colors, depending on the player's choice.
  23. Optimized visibility-detection, to reduce cpu overhead.
  24. Units automatically moving towards detected enemies out of their attack range.
  25. Subdivided FogOfWar SpriteList to optimize FoW updates performance.
  26. Shot, hit and destruction graphic effects and sounds.
  27. Simple minimap showing current viewport position and revealed map area.
  28. Vehicles leave tires/tracks traces on the ground.
  29. When Vehicles are destroyed, they leave wrecks.
  30. Implemented pooling to boost Explosions efficiency.
  31. Implemented in-game timer displaying how much time passed since game started.
  32. Implemented new game-loading from file system.
  33. Added playlists for background music tracks. 10.06.2021:
  34. Improved mini-map: better resolution, no more ugly big rectangles!
  35. Saving Trees works now!
  36. Loading menu with auto-updating list of existing save-files. 28.06.2021:
  37. UI for Buildings and Units-production added.
  38. Player can now produce new units.
  39. Soldiers can enter end leave Buildings.
  40. UI displays amount of resources, player has. 17.03.2023:
  41. New UI with icons for resources and units and buildings construction panels.
  42. Prettier Fog Of War without sharp edges.
  43. Units are now rotated in 16 directions instead of 8.
  44. CPU-player can now build Units, having enough resources and proper factories.
  45. Added two more units prototypes - Truck and APC.
  46. Minimap and teleporting to the map-locations by clickling on the minimap (was added long time ago, but I missed noticing it).

TO BE DONE:

Minor:

  1. Improve visibility-detection by 'communicating' what is seen between friendly Units which are very close to each other.
  2. Improve collisions-avoidance to get rid off the diagonal-movements-collisions.
  3. Better collision-avoidance to replace tiles-reserving system - flocking maybe? How to make it working with pathfinding?
  4. Units-radiochatter sounds - DONE. Battle sounds.
  5. Skirmish mission customisation submenu (this is the only available game mode for now).
  6. Playlist for background music tracks - DONE.
  7. Better Ai for Units autonomous behaviour.
  8. Flocking for Soldier class.
  9. Implement Jump Point Search to optimize A* performance.
  10. Less cpu-heavy VehicleThreads.
  11. Nicer MiniMap without ugly rectangles representing discovered area - DONE.

Major:

  1. User-interface. (currently being developed)
  2. Menu! (currently being developed)
  3. AI (with finite-state=-machine?)
  4. Saving and loading game (with shelve?) - DONE
  5. Sounds and music - DONE
  6. Multiplayer.
  7. "Playing" section above.
  8. Installer/executable for Windows and Linux.
  9. Docker image.

Gameplay mechanics:

  1. Many various resources consumed to produce units and maintain infrastructure and extracted in different ways.
  2. Technological advancement system - researching new technologies allows player to build better units and buildings.
  3. Conscription system: to build units, especially infantry, player needs to create recruitments facilities near civilian villages and protect them from enemies.
  4. Supply-transportation and storage system. Units do not have infinite ammunition and fuel and require to be resupplied from base by the supply-transporting vehicles. Protecting supply-lines is required.

Rafał "Akapkotel" Trąbski

python_real_time_strategy_game's People

Contributors

akapkotel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

python_real_time_strategy_game's Issues

Optimize FogOfWar render.

Each frame there are dozens of dog sprites rendered and each Unit is 'revealing' a portion of the fog of war which must be updated and redrawn.

There must be a way to do it faster.

Enemies-detection is bugged on isometric map

Units have some strange issues with detecting and keeping track of detected enemies on isometric map. They "forget" about detected enemies, and sometimes they do not detect them at all.

Add ColorPicker to scenario editor and game menu

User interface require some kind of color-picking interface when game is in editor mode. Is should also be added to the submenu of custom game.

  1. Need new UiElement class.
  2. ScenarioEditor class should have an player_color attribute.

Isometric quadtree for non-square maps are fucked up

When map width/height ratio is not 2:2 (it is not an isometric square) - the Quadtree goes mad and it's quads does not align with map boundaries and further divides goes wild.

Find the way to correctly generate Quadtrees for non-square iso-maps.

Use Tiles coordinates to faster spatial checks in QuadTree

For now each Unit is testing, if it's QuadTree should be chanmged every time that Unit moves to another Tile. It lead to in_bounds() method call, which is expensive.

If currently occupied Tile would be 'informed' by the QuadTree, that it belongs to that quad, Units could querry their current Tiles for QuadTree id instead of calling in_bounds() method.

Must implement and test.

Optimize text drawing in the UI

Examining game with pyprofiller showed, that text-drawing calls from arcade library consumes huge amount of time: 21 seconds out of total code execution time 114 seconds!

So, draw_text call is a bottleneck.

draw_text

FogOfWar does not work with IsometricMap

Instantiating FogOfWar is impossible with isometric map. It causes that Units are not working properly, and even Cursor crashes game when you select an Unit because there is a check for Fog on screen to decide whic cursor texture should be rendered.

Optimize mini-map render

Another bottlenec is the MiniMap class which takes 23 seconds out of total 114 seconds of code execution time according to the pyprofiller!

minimap

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.