WIP python/pygame 2D zombie shooter

Overview

2d-shooter project

A single/multiplayer co-op survival small space zombie shooter.

If you'd like to contribute, feel free to join the discord!

INSTALL

  1. Clone repo and extract the zip
  2. Copy the directory of the game
  3. Open command prompt and type in "cd directory/of/game" (i.e "cd C:\tmp\2dshooter")
  4. Type in "pip install -r requirements.txt"
  5. Run RUN.py

SET-UP.

MULTIPLAYER

Multiplayer works currently within local network right now. You can play against your friends either in local wifi, or by installing LogMeIn Hamachi VPN.

  1. Install Hamachi from https://www.vpn.net/
  2. Create a new network.
  3. Share the name and password of the network to your friends.
  4. Enable python's access through your firewall
  5. Once everyone is in the same network, your in-game ip address should change to your Hamachi ipv4. This can be seen in the multiplayer tab.
  6. Host a game, and share your ip with your friends.
  7. Start the game.

CONTROLS

WASD MOVEMENT.

Shift to run. Space to dash. Control to sneak.

MOUSE CONTROLS GUN.

aim by angle of mouse to player, the bullet spread is determined by movement and recoil.

TAB OPENS INVENTORY

where you can drag things from boxes with your mouse and store them.

F SEARCHES BOXES

opens both the box and your inventory: manipulation is done via mouse. Shift-click to quickly transfer the item to your inventory.

G THROWS GRENADES

throws a grenade about where the mouse is.

USING ITEMS

For items that are useable/placeable: right click on them. In the case of barricades: highlight the ground where you want to place the barricade - green is placeable, red is not.

Given enough time barricades will fall under the horde.

MIND YOUR SANITY

Consume narcotics to regain sanity and survive.

TODO

current list of todos

Comments
  • fs_size and larger screens

    fs_size and larger screens

    so here is the error I found.

    Traceback (most recent call last):
      File "2dshooter/RUN.py", line 522, in <module>
        s7_2 = button7_2.tick(screen, mouse_pos, mouse_single_tick, glitch)
      File "2dshooter/RUN.py", line 236, in tick
        return self.action(self.args)
      File "2dshooter/RUN.py", line 139, in start_sp
        game.main(difficulty = arg, draw_los = draw_los, dev_tools = dev, skip_intervals = check_box_inter.__dict__["checked"], map = maps_dict[selected_map]["map"])
      File "2dshooter/game.py", line 1223, in main
        pygame.transform.scale(screen, fs_size, full_screen)
    ValueError: Destination surface not the given width or height.
    

    there's some recap: I have a 4k monitor, and I noticed this in the code.

    fs_size = 1920, 1080
    

    game would not start (I hear some music and a black screen, then it crashes)- it would give this error at start:

    anim/glitch/0010.png
    RESET
    Traceback (most recent call last):
      File "2dshooter/RUN.py", line 658, in <module>
        pygame.transform.scale(screen, fs_size, full_screen)
    ValueError: Destination surface not the given width or height.
    

    when I changed the fs_size var to be:

    fs_size = 1920*2,1080*2
    

    which is my resolution, the loading screen starts up. everything looks fine. the latest error (the top one of this post) happens when I hit start game on single or multiplayer after I made that change.

    It's also hard for me to debug - because when I run the debugger in vscode - whatever screen the terminal is displayed in is the one pygame (not the monitor pygame is in ) seems to want to measure and get the dimensions of. (so I can't seem to have vscode open on the side and pygame on the center monitor without producing a

    ValueError: Destination surface not the given width or height.
    

    at some point - because of some mismatch of measurement.

    I'll try another DE and maybe it's just an I3 thing, but I think it's a 4k/1080p or a (single/dual monitor ?) thing.

    opened by altruios 12
  • func.calc_route() grinds the game into a halt, when player is in certain spots

    func.calc_route() grinds the game into a halt, when player is in certain spots

    The function does not work properly, since it finds infinite routes for some reason, so I just break the loop after certain amount of time. Usually it finds some route, but in certain spots (in Manufactory in top right corner) the zombies don't find any route so they try to calculate a new route every tick, grinding the game in to halt.

    `def calc_route(start_pos, end_pos, NAV_MESH, walls): """ Calculates the shortest route to a point using the navmesh points """

    if los.check_los(start_pos, end_pos, walls):
        return [end_pos]
    dist_start = {}
    dist_end = {}
    for nav_point in NAV_MESH:
        point = nav_point["point"]
        if los.check_los(start_pos, point, walls):
            dist_start[los.get_dist_points(start_pos, point)] = nav_point
        if los.check_los(end_pos, point, walls):
            dist_end[los.get_dist_points(end_pos, point)] = nav_point
    try:
        start_nav_point = dist_start[min(dist_start.keys())]
        end_nav_point = dist_end[min(dist_end.keys())]
    except:
        return [end_pos]
    
    
    complete_routes = []
    routes = []
    for conne in start_nav_point["connected"]:
        routes.append([start_nav_point["point"], conne])
    
    while routes != []:
        if len(routes) > 200:   #sometimes continues infinetely, so the loop must be broken
            break
        route = routes[0]
        routes.remove(route)
        point = route[-1]
        point_2 = get_point_from_list(point, NAV_MESH)
        if end_nav_point["point"] in point_2["connected"]:
            route.append(end_nav_point["point"])
            complete_routes.append(route)
    
        else:
            for point_3 in point_2["connected"]:
                if point_3 in route:
                    continue
                if route.copy() + [point_3] in routes:
                    continue
                routes.append(route.copy() + [point_3])
    shortest_route = {"dist" : 10000, "route" : []}
    
    
    for route in complete_routes:
        route_ref = {"dist" : 0, "route" : route}
        last_pos = start_pos
        for point in route:
            route_ref["dist"] += los.get_dist_points(last_pos, point)
    
        if route_ref["dist"] < shortest_route["dist"]:
            shortest_route = route_ref
    
    return shortest_route["route"]`
    
    opened by dille12 6
  • Crashed while playing  [https://github.com/dille12/2dshooter/pull/29]

    Crashed while playing [https://github.com/dille12/2dshooter/pull/29]

    Zombie spawned with id 2292 Zombie spawned with id 3799 Zombie spawned with id 2694 Zombie spawned with id 908 Zombie spawned with id 2981 Zombie spawned with id 3522 Zombie spawned with id 2547 Zombie spawned with id 2555 Zombie spawned with id 2949 EXPLOSION ADDED Zombie spawned with id 1227 Zombie spawned with id 1894 Zombie spawned with id 2729 Zombie spawned with id 215 Zombie spawned with id 608 Zombie spawned with id 3177 Zombie spawned with id 3805 Zombie spawned with id 4026 Dropping: {'item': <classes.Item object at 0x000000000EA30708>, 'amount': 1} Zombie spawned with id 42 DROP: 33.32363348513192 {33.32363348513192: ['HE Grenade', 0], 29.32363348513192: ['Heroin', 4], 28.77363348513192: ['Cocaine', 4.55], 27.773 48513192: ['Diazepam', 5.55], 25.77363348513192: ['45 ACP', 7.55], 18.77363348513192: ['50 CAL', 14.55], 15.773633485 92: ['9MM', 17.55], 9.77363348513192: ['12 GAUGE', 23.55], 6.773633485131921: ['7.62x39MM', 26.55], 3.773633485131920 ['Sentry Turret', 29.55], 0.7736334851319242: ['Barricade', 32.55]} KEY 32.55 DROP 33.32363348513192 Zombie spawned with id 794 Zombie spawned with id 591 Zombie spawned with id 1082 Zombie spawned with id 3930 Zombie spawned with id 879 STILL TO BE REMOVED: 5 STACK AMOUNT: 5 0 DELETING SLOT Zombie spawned with id 1896 Dropping: {'item': <classes.Item object at 0x000000000EA30708>, 'amount': 1} GRENADE INIT STILL TO BE REMOVED: 1 STACK AMOUNT: 2 1 throwing nade HIT Traceback (most recent call last): File "RUN.py", line 558, in main() File "RUN.py", line 419, in main s7_2 = button7_2.tick(screen, mouse_pos, mouse_single_tick, glitch) File "C:\python\2dshooter-contrib\button.py", line 63, in tick return self.action(arg) if arg != None else self.action(self.args) File "RUN.py", line 125, in start_sp app.start_sp(args) File "C:\python\2dshooter-contrib\app.py", line 40, in start_sp full_screen_mode = full_screen_mode) File "C:\python\2dshooter-contrib\game.py", line 1072, in main x.tick(screen, map_boundaries, player_pos, camera_pos, grenade_list, explosions, expl1, map, walls_filtered) File "C:\python\2dshooter-contrib\armory.py", line 155, in tick self.molotov_explode(map) File "C:\python\2dshooter-contrib\armory.py", line 117, in molotov_explode grenade_list.remove(self) ValueError: list.remove(x): x not in list

    opened by Velas2 1
  • Refactor

    Refactor

    Hey I came from reddit and these are my suggestions for you

    • use F-strings instead of concatenation
    • use one-line if/else statements as you can !
    • return immediately in functions instead of declaring extra variable
    • use comprehensions
    • merge nested if statements
    • use CONSTANT variables (for example you can have something like : WHITE_COLOR = [255,255,255] instead of repeating the color code many times)
    • use with keyword for opening/closing files

    we should apply these rules as far as the code readability stay safe, good luck

    opened by fristhon 1
  • get_monitors missing..

    get_monitors missing..

    C:\python\2dshooter>python RUN.py pygame 2.1.2 (SDL 2.0.18, Python 3.7.4) Hello from the pygame community. https://www.pygame.org/c Traceback (most recent call last): File "RUN.py", line 6, in from values import * File "C:\python\2dshooter\values.py", line 7, in <modul from screeninfo import get_monitors ModuleNotFoundError: No module named 'screeninfo'

    opened by Velas2 1
  • Update todos.md

    Update todos.md

    Added top links to subjects - added sub categorization of todos. Note important to do is adding testing and getting automatic testing working in github. I'm not familiar with testing suites with python (just javascript) - so can't give any usable recommendations

    opened by altruios 1
  • Bump numpy from 1.20.1 to 1.21.0

    Bump numpy from 1.20.1 to 1.21.0

    Bumps numpy from 1.20.1 to 1.21.0.

    Release notes

    Sourced from numpy's releases.

    v1.21.0

    NumPy 1.21.0 Release Notes

    The NumPy 1.21.0 release highlights are

    • continued SIMD work covering more functions and platforms,
    • initial work on the new dtype infrastructure and casting,
    • universal2 wheels for Python 3.8 and Python 3.9 on Mac,
    • improved documentation,
    • improved annotations,
    • new PCG64DXSM bitgenerator for random numbers.

    In addition there are the usual large number of bug fixes and other improvements.

    The Python versions supported for this release are 3.7-3.9. Official support for Python 3.10 will be added when it is released.

    :warning: Warning: there are unresolved problems compiling NumPy 1.21.0 with gcc-11.1 .

    • Optimization level -O3 results in many wrong warnings when running the tests.
    • On some hardware NumPy will hang in an infinite loop.

    New functions

    Add PCG64DXSM BitGenerator

    Uses of the PCG64 BitGenerator in a massively-parallel context have been shown to have statistical weaknesses that were not apparent at the first release in numpy 1.17. Most users will never observe this weakness and are safe to continue to use PCG64. We have introduced a new PCG64DXSM BitGenerator that will eventually become the new default BitGenerator implementation used by default_rng in future releases. PCG64DXSM solves the statistical weakness while preserving the performance and the features of PCG64.

    See upgrading-pcg64 for more details.

    (gh-18906)

    Expired deprecations

    • The shape argument numpy.unravel_index cannot be passed as dims keyword argument anymore. (Was deprecated in NumPy 1.16.)

    ... (truncated)

    Commits
    • b235f9e Merge pull request #19283 from charris/prepare-1.21.0-release
    • 34aebc2 MAINT: Update 1.21.0-notes.rst
    • 493b64b MAINT: Update 1.21.0-changelog.rst
    • 07d7e72 MAINT: Remove accidentally created directory.
    • 032fca5 Merge pull request #19280 from charris/backport-19277
    • 7d25b81 BUG: Fix refcount leak in ResultType
    • fa5754e BUG: Add missing DECREF in new path
    • 61127bb Merge pull request #19268 from charris/backport-19264
    • 143d45f Merge pull request #19269 from charris/backport-19228
    • d80e473 BUG: Removed typing for == and != in dtypes
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • added tests to stuff i added earlier

    added tests to stuff i added earlier

    empty tests... but hopefully I or someone will fill them out.

    and a minor change with get_string - now inherits from Weapon / game_object. cleaner code.

    opened by altruios 0
  • NameError: name 'turret_rect' is not defined - turret.py - line 116, in clean_up

    NameError: name 'turret_rect' is not defined - turret.py - line 116, in clean_up

    {35.18666611632174: ['HE Grenade', 0], 31.18666611632174: ['Heroin', 4], 30.636666116321738: ['Cocaine', 4.55], 29.63666 6116321738: ['Diazepam', 5.55], 27.636666116321738: ['45 ACP', 7.55], 20.636666116321738: ['50 CAL', 14.55], 17.63666611 6321738: ['9MM', 17.55], 11.636666116321738: ['12 GAUGE', 23.55], 8.636666116321738: ['7.62x39MM', 26.55], 5.63666611632 1738: ['Sentry Turret', 29.55], 2.6366661163217415: ['Barricade', 32.55], 0.6366661163217415: ['Molotov', 34.55]} KEY 34.55 DROP 35.18666611632174 Zombie spawned with id 1341 Zombie spawned with id 3116 Zombie spawned with id 1558 PARTICLE IN WALL, KILLING PARTICLE IN WALL, KILLING PARTICLE IN WALL, KILLING PARTICLE IN WALL, KILLING PARTICLE IN WALL, KILLING PARTICLE IN WALL, KILLING Zombie spawned with id 3662 Traceback (most recent call last): File "RUN.py", line 601, in main() File "RUN.py", line 462, in main s7_2 = button_start_mp.tick(screen, mouse_pos, mouse_single_tick, glitch) File "C:\python\2dshooter-contrib\button.py", line 61, in tick return self.action(arg) if arg != None else self.action(self.args) File "RUN.py", line 137, in start_sp app.start_sp(args) File "C:\python\2dshooter-contrib\app.py", line 42, in start_sp full_screen_mode = full_screen_mode) File "C:\python\2dshooter-contrib\game.py", line 339, in main quit_button.tick(screen, mouse_pos, click_single_tick, glitch) File "C:\python\2dshooter-contrib\button.py", line 61, in tick return self.action(arg) if arg != None else self.action(self.args) File "C:\python\2dshooter-contrib\game.py", line 71, in quit RUN.main() File "C:\python\2dshooter-contrib\RUN.py", line 462, in main s7_2 = button_start_mp.tick(screen, mouse_pos, mouse_single_tick, glitch) File "C:\python\2dshooter-contrib\button.py", line 61, in tick return self.action(arg) if arg != None else self.action(self.args) File "C:\python\2dshooter-contrib\RUN.py", line 137, in start_sp app.start_sp(args) File "C:\python\2dshooter-contrib\app.py", line 42, in start_sp full_screen_mode = full_screen_mode) File "C:\python\2dshooter-contrib\game.py", line 631, in main x.tick(screen, camera_pos,enemy_list,0, walls_filtered, player_pos) File "C:\python\2dshooter-contrib\game_objects\turret.py", line 125, in tick self.clean_up() File "C:\python\2dshooter-contrib\game_objects\turret.py", line 116, in clean_up func.render_cool(huuto,[turret_rect[0]+35-camera_pos[0], turret_rect[1]+35-camera_pos[1]],self._tick,16,True, screen = screen) NameError: name 'turret_rect' is not defined

    opened by Velas2 0
  • AUTO TESTING ADDED

    AUTO TESTING ADDED

    no tests are actually written: but the automatic testing for github PR's and pushes are done. I had some trouble actually hooking up x11 or any display in the github container - so dummy driver for testing should be fine. to facilitate that I added a try block in values to have a default fallback if screeninfo fails (it does in the testing env - and that looks like it might be a package issue over there.) now we just need to write tests...

    opened by altruios 0
  • refactor weapons and items - up and running stage

    refactor weapons and items - up and running stage

    as far as I can currently tell - everything is up and running.

    if anything is broken it should only be a minor fix.

    further cleanup will be done - this could still be a lot better

    todo: make it so the general object handles outside interactions - and sub_objects can be 'pure', in that they don't require anything from values/func/classes etc. making them easier to test.

    opened by altruios 0
  • socket.gethostbyname(hostname) might not return a correct ip

    socket.gethostbyname(hostname) might not return a correct ip

    Friend of mine checked the multiplayer tab and the ip text bar showed his local ip, even though it should be his public ipv4 address. ipv4 is crucial for the multiplayer. Can anyone check the tab and see if your correct ipv4 shows up?

    opened by dille12 14
Releases(v0.1)
用于 blivechat 的图形界面

blivechat GUI 用于 blivechat 的图形界面。 有朋友在搞 Vtuber,像 blivechat 类似的项目能通过自定义 CSS 的方式在 OBS 上添加一个非常好看的聊天栏。但是想要在桌面端看到弹幕的话得要再开一个浏览器页面,十分不方便。就想写一个背景透明的浮窗浏览器。 挺喜欢

Silence 11 Dec 29, 2022
Tic-Tac-Toe - Tic-Tac-Toe game build With Python

Tic Tac Toe This game is very popular amongst all of us and even fun to build as

PyLaboratory 0 Feb 06, 2022
A pygame implementation of John Conway's Game of Life

Game of Life A Pygame Simulation This is a Pygame implementation of the famous Conway's Game of Life. The game features a set of very simple rules: An

1 Jan 06, 2022
Automatic game data translator for RPGMaker-MV

RPGMaker-MV Translator 🕹️ 🎮 Use AI to translate all the dialogs and texts of your RPGMaker automatically. 👊 You worked hard to make your game, now

Davide Liu 11 Dec 26, 2022
2D Minecraft Clone made with Python & Pygame & OpenGL

2D Minecraft Clone This is a 2D clone of the well-known game Minecraft made in Python using Pygame and ModernGL I started this mostly as a self-improv

Kadir Aksoy 2 Sep 25, 2022
Disables the chat in League of Legends for Windows.

Disables the chat in League of Legends for Windows. If you simply can't stop yourself from typing LeagueStop will play KEKW.mp3 each time you try. The sound will stack & becomes horribly annoying.

1 Nov 24, 2021
A python script to solve Wordle puzzles

Wordle solver A python script to solve Wordle puzzles.

Felix Weinberger 1 Feb 12, 2022
A Pygame Hangman Game coded in Python 3. Run Hangman.py in a terminal if you have Python 3

Hangman A Pygame Hangman Game coded in Python 3. Run python3 Hangman.py in a terminal if you have Python 3.

1 Dec 24, 2022
PingPong - Simple Ping Pong Game Made In Python

PingPong Basic Ping Pong Game Made In Python

ʀᴇxɪɴᴀᴢᴏʀ 1 Jan 01, 2022
Flappy-Bird AI - Flappy Bird game with AI

FLAPPY BIRD AI Flappy Bird game solved with neat-python, a Python module based o

1 Jan 07, 2022
Play a game of Phazed with a bot or with other players or watch bots play with each other

Phazed Game and Player play a game of Phazed with a bot or with other players or watch bots play with each other Live Demo hosted on repl.it (makes su

Xin Yu 0 Aug 28, 2021
Several implementations of classical games (ex: FlappyBird, Minesweeper etc.) using Python (pygame)

Mini Games with Pygame This projects implement several classic and popular games in Python, using python package -- pygame. Currently, 4 games are alr

1 Feb 14, 2022
user friendly python script who is able to catch fish in the game New World

new-world-fishing-bot release 1.1.1 click img for demonstration Download guide Click at latest release: Download and extract bot.zip: When you run fil

297 Jan 08, 2023
Jogo da velha escrito em python para 1 ou 2 jogadores

O Jogo da Velha Esse jogo da velha foi desenvolvido por mim em python, como um desafio de programar um jogo da velha em menos de 24 horas, no qual o c

Gabriel Castelo Branco 5 Jun 18, 2021
The original Tetris tile-matching game as adopted by IBM PC.

🕹️ Tetris Game The original Tetris tile-matching game as adopted by IBM PC. Game developed purely on python using the Dear PyGui Framework. 📖 Instru

14 Nov 12, 2022
Python Knots and Crosses game, with customizable markers and more!

Knot-and-Crosses Python Knots and Crosses game, with customizable markers and more! Features: Ability to change your marker Ability to change how many

4 Nov 07, 2021
A puzzle game coded entirely in Python.

Pyzzle A puzzle game coded entirely in Python. This is a school project created by me, Mohit Singh. The .exe file, created from the main.py script, is

Mohit Singh 1 Mar 19, 2022
Chess - A python gui application

Chess Python version 3.10 or greater is required to play. Note This is a gui application, and as such will not run inside WSL.

Jonxslays 1 Dec 16, 2021
Trio Assembly Snakemake Workflow

Trio Assembly Snakemake Workflow Input HiFi reads for child in bam format Either

Juniper A. Lake 1 Jan 28, 2022
A short non 100% Accurate Solar System in pygame

solar-system-pygame Controls UP/DOWN for Emulation Speed Control ESC for Pause/Unpause q to Quit c or ESC again to Continue LEFT CLICK to Add an orbit

LightCrimson 2 May 28, 2022