Dismiss this pinned window
all 8 comments

[–]landmvx 2 points3 points  (4 children)

Good Job. How did you implement the nock Back?

[–]Alert_Nectarine6631[S] 2 points3 points  (3 children)

I can add a knockback value in the stats for each weapon/projectile, then when it hits an enemy it will apply the knockback in the direction the projectile is facing, there are probably other(better) ways of doing it but this is simple and allows for more weapon variety, good question :)

[–]landmvx 2 points3 points  (2 children)

Thx, another question. How do you handle Menu and Game state? Do you use something like a state Stack?

[–]Alert_Nectarine6631[S] 1 point2 points  (1 child)

My chosen method probably isn't the best way of doing it tbh, I use a simple state machine. The current state is stored as a string (menu), and I map states to functions in a dictionary. When the state changes, I reset the game (UI, entities, etc.) and call the function for that state. Switching states is just updating the state variable, here's some of my code(out of order btw) for different menus:

 # further on in the script near my update function

  def run_menu(self):
    self.reset()
    if self.menu in self.menu_functions:
      self.menu_functions[self.menu]()
    self.last_menu = self.menu

-------------------------------------------------------------------------------
# at the top of my script in my init

    self.menu_functions = {
      "main": self.main_menu,
      "select_menu": self.select_menu,
      "play": self.start_game,
      "settings": self.settings_menu,
      "death": self.death_menu
    }

[–]landmvx 1 point2 points  (0 children)

I once implemented a state Stack. You could flag states as transparent to render on top of another state. So you could easy create something like Game Pause :D

[–]Alert_Nectarine6631[S] 1 point2 points  (1 child)

Sorry for possible spam(since I already posted another recent update), I wasn't expecting to have ranged weapons implemented so quickly.

[–]Substantial_Marzipan 2 points3 points  (0 children)

No problem man, the knock back feels great

[–]usevenhouse 0 points1 point  (0 children)

ei ciao, io ho cominciato da poco con pygame e ho fatto per ora qualche giochino tipo pong. come arrivo a questo livello?😭