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)
Owner
null
A top-down arcade space shooter made in pygame.

About: Journey Through Space is a top-down arcade shooter made in pygame. You play as a pilot who was left behind after a battle and the goal is to go

Crimson Sane 0 Jan 1, 2022
A zombie game using Kinetic. You can control players using fingers

This is Eden Park's portpolio: Works, projects and practices This repository can be used to show the potential employers to check my works, code and p

Eden Park 4 May 16, 2022
PyGame-Tutorial - Refrence for building games in pygame

PyGame-Tutorial How to build games using the python library PyGame End result Ho

St. Mark's Computer Science Club 2 Jan 9, 2022
Arcade-like space shooter game written entirely in python

E.T.-Attack Arcade-like space shooter game written entirely in python Project description A space shooter game - inspired by the legendary game Space

Sven Eschlbeck 2 Dec 17, 2022
3D online shooter written on Panda3D 1.10.10 and Python 3.10.1

на русском itch.io page Droid Game 3D This is a fresh game that was developed using the Panda3D game engine and Python language in the PyCharm IDE (I

Marcus Kemaul 5 Jun 4, 2022
Simple Covid-19 shooter game in python.

Covid_game ?? Simple Single Player Covid Game Using Python. ?? Has amazing background music theme. ?? Game Instructions: Initial Health is 5, try to s

Tanya Yadav 2 Aug 5, 2022
Space shooter being built for PyWeek 32

Axium Humanity's expansion into space had lasted centuries by the time we encountered the vicious Threx. The Threx adopted a single, religious mission

Daniel Pope 6 Oct 28, 2021
Navicella cavallo, gioco 2D stile space shooter

Navicella Cavallo Il miglior gioco in circolazione Navicella cavallo è un gioco 2D basato sullo stile dei giochi space shooter Come installare Navicel

Matteo 6 Jul 3, 2022
Cheats for shooter games

Cheats Cheats for shooter games Download Trigger Bot trigger.exe // trigger.sha256 Download Certify Bot certify.exe // certify.sha256 Note: Check sha2

Emin Muhammadi 1 Nov 26, 2021
BitBot - A simple shooter game

BitBot BitBot - A simple shooter game This project can be discontinued anytime I want, as it is not a "MAJOR" project for me. Which Game Engine does i

whmsft 1 Jan 4, 2022
A shooter game.

Screenshots Installation GNU/Linux Go to the Releases tab. Download InfiniteShooter.flatpak from the latest version of InfiniteShooter Open the termin

PastThePixels 13 Dec 1, 2022
pygame is a Free and Open Source python programming language library for making multimedia applications like games built on top of the excellent SDL library. C, Python, Native, OpenGL.

pygame is a Free and Open Source python programming language library for making multimedia applications like games built on top of the excellent SDL library. C, Python, Native, OpenGL.

pygame 5.6k Jan 1, 2023
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.

null 1 Dec 24, 2022
Simple Game created using Python & PyGame, as my Beginner Python Project!

Space Invaders This is a simple SPACE INVADER game create using PYGAME whihc have sound and lot's of keyboard functions. Prerequisites More Experience

Gaurav Pandey 2 Jan 8, 2022
Wordle-Python - A simple low-key clone of the popular game WORDLE made with python and a 2D Graphics module Pygame

Wordle-Python A simple low-key clone of the popular game WORDLE made with python

Showmick Kar 7 Feb 10, 2022
Quiz game made entirely with python and pygame for school work

Tabela de conteúdo Descrição Como instalar Linguagens usadas Contribuidores Créditos Problemas com o jogo? Contate-nos Descrição Quiz feito inteiramen

null 3 Apr 12, 2022
A simple matrix code rain created using Python with Pygame.

Matrix4_code_rain A simple matrix code rain created using Python with Pygame. To run the code you will need Pygame and MS Mincho font. Create a projec

null 7 Nov 6, 2022
FlappyBird game with python and pygame

FlappyBird game with python and pygame

Mohammad Dori 4 Jul 15, 2022
A Frogger game in Python with pygame

CrockiCrocki A personal project of a simple "game" in Python to learn Pygame and Python. Requires: pygame: In Linux: pip3 install pygame In MacOS: pip

Jorge Abreu 1 Nov 7, 2021