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)
A fun, casual and strategic game made using Python!

Steve's Pixels A fun, casual and strategic game made using Python! Prerequisites See requirements.txt Demo video demo.mp4 Usage python -m steves_pixel

Jaivardhan Bhola 9 Sep 17, 2022
Battle of Saiyans: Goku v Vegeta is a 1 v 1, (Player vs CPU) 2D Martial arts fighting game

Battle of Saiyans: Goku v Vegeta is a 1 v 1, (Player vs CPU) 2D Martial arts fighting game inspired by the popular anime series Dragon Ball Z The game

ARZ 3 Feb 16, 2022
Guess number game with PyQt5

Guess-Number-Project Guess number game with PyQt5 you can choose a number in your mind and then computer will guess a nummber and you guide the comput

MohammadAli.HBA 1 Nov 11, 2021
A bot that deletes any embeds sent by a tropical webhook containing hex #000000 rancher's boots

tropical-webhook-cleanup how to use download the source code as zip get your discord bot token from https://discord.com/developers/applications put yo

carreb 0 Nov 25, 2022
Meu primeiro jogo desenvolvido em Python, usado o módulo do Pygame

📖 Sobre Esse repositório é dedicado ao meu primeiro jogo feito em Python, utilizando o módulo do pygame. O jogo foi desenvolvido seguindo o tutorial

Michael Douglas 0 May 06, 2022
Launcherpi - Minecraft Launcher for Raspberry Pi computers

launcherpi Minecraft Launcher for Raspberry Pi computers. ASLO BIG THANKS TO KLO

8 Sep 24, 2022
This is an interactive MiniMap made with Python, PyQT5 & Pytesseract for the game

NWMM-New-World-MiniMap Features: Automatically grabs position from "New World" Instance Live visualisation of player position on MiniMap Circular & re

Nezzquikk 18 Sep 21, 2022
Crazy fast kahoot game flooder with a GUI and multi OS support.

kahoot flooder Crazy fast kahoot game flooder with a GUI and multi OS support. Made in python using tkinter and KahootPY with toast notifications. Req

Ben Tettmar 1 Apr 09, 2022
Discord.py Gaming Bot🎮, for fun & engaging discord minigames

Status 🧭 This Project will not no longer be developed/finished due to a) discord.py's ( main dependency ) discontinuation b) My personal lack of int

Wordsetter 11 Nov 21, 2022
Basic Python physics library.

pythonPhysics Basic Python physics library. Must have pygame installed. How to: Sketon program is included. for p in env.particles: pygame.draw.circle

1 Jan 16, 2022
Deal Or No Deal was a very popular game show. Even now, for a family party, it's a fun game to pass time

Deal Or No Deal was a very popular game show. Even now, for a family party, it's a fun game to pass time. I made a code to play the game right in your terminal/console. This isn't made to be a game w

1 Feb 15, 2022
Exposè for i3 WM. Fork of https://gitlab.com/d.reis/i3expo to fix crashes and improve features/usability

Overwiew Expo is an simple and straightforward way to get a visual impression of all your current virtual desktops that many compositing window manage

137 Nov 03, 2022
Simple car game written in PyGame

Welcome to CarGame 👋 Car Game written in PyGame! NOTE: This is still new and there may be stuff broken... 🏠 Homepage Install install pygame by typin

John 1 Oct 29, 2021
A Tetris game made using PyGame as renderer only, for a school project.

Tetris_Python A Tetris game made using PyGame as renderer only, for a school project. Twist in the Game Blocks can pentrate through right and left bou

Ravi Arora 2 Jan 31, 2022
MiTM proxy server for Darza's Dominion

Midnight A MiTM proxy server for Darza's Dominion, PC version. See this video for a demonstration of godmode: https://youtu.be/uoqvSxmnCJk How to use

2 Oct 24, 2022
This is the card game like HearthStone and Magic

Territory War How to use it use pip3 to install django and channels: pip3 install Django pip3 install channels go to CardGame/first/consumers.py and g

Caesar 3 Oct 24, 2022
HackNC 2021 Project

pyTunes HackNC 2021 Project Setting Up Once the repo is cloned, install the requirements through pip install -r ./requirements.txt Once that is done,

Demo 1 Nov 07, 2021
An open-world game made in Python.

Dragon Realms Notes Windows OS only Contributors This project follows the all-contributors specification (emoji key, command Issue). See what you can

Dragon Realms 2 Jul 28, 2022
Guess The Random Number - A sample Random Number Guessing Game Python Program

Guess_The_Random_Number This repo contains a simple "Random Number Guessing Game

Pramod Kumar 3 Feb 09, 2022
Vac-Man in Python

Vac-Man in Python This is my personal version of Vax-man game using python, which is the first task of EA Software Engineering Virtual Experience Prog

ZiXiang Luo 3 Jan 05, 2022