2022-01-24 21:58:27

Hello ladies and gentlemen, so the short of it is, after spending months messing around with mods for Tactical Battle and Swamp, and coming to the realization that on neither of these two, to be completely fair, quite delightful games, could I construct my vision of the sort of game I’d like to craft in a manner which satisfied me: against my better judgment, and in determination not to let the BGT hell lord corrupt my sole, I’ve decided to dip my tows again into trying to create a little something from scratch with python. My ultimate goal would be to fashion a top down single player squad based shooter, in the same vain as 1942 and Jupiter Hell, which are both the inspiration behind this little project. However, given that my level of programming expertise extends to basic terminal based programs, I was wondering if there are some open source python audio game examples that I could take a look at to get me started in how one should go about constructing a game in the first place, ie, some base information on how to create and handle menus, saving, etc, cause that’s where I’m currently struggling with?

Hit up my YouTube Channel at
https://www.youtube.com/channel/UCC9wWO … R85ILY1VQ/
Their you'll find some gaming videos, and what ever els my confused mess of a brain decides to upload. Hope you enjoy it and Stay safe, folks.

2022-01-24 23:02:45

In turms of complete, feature ritch audiogames, I think you and me are out of luck. Menus are litterally just lists. You can have a keypress move down the list, while having a for loop iterating over it and stopping at your current option and saying it. I'm sure there is a better way to do this, but for simple menus it should do the trick.
Savin g is an interesting beast, if you want unreadable savefiles I'm not sure, but you could experiment with pickle and see how that works.  We seem to be in the same stage of the programming latter. What I will leave you with is this, Google is your friend. Use it for anything you don't know as it can probably help you more than we can in a timely fattion.

2022-01-24 23:45:34

You don't need a for loop for a menu necessarily. Just have an index variable that keeps track of your position in the menu and then do someSpeechFunction(menuItems[index]).

Deep in the human unconscious is a pervasive need for a logical universe that makes sense. But the real universe is always one step beyond logic.

2022-01-25 00:52:03 (edited by amerikranian 2022-01-25 00:55:12)

Hey. Welcome to the fold. First. Do not limit yourself to just looking up stuff about audio games. You will seldom find what you're looking for. Generalize your searches to something like "saving in games" or "saving game state" or what have you. Point is, though you're gonna get some info about graphics, the core concepts still apply. That being said, I do have a few links for you.
Sound RTS on Github. I know. You mentioned it fitting your vision, but I believe that Sound RTS can show you what to do, even if being dense at times. I am also a big proponent of exposure, meaning I personally love seeing things that you should not do and apply what you've learned in your future projects.
This is one of my older projects, but I believe it can show you a thing or two with the benefit of being a lot more less complex. Though the coding style is... less than superb, I think it still demonstrates the basics of keyboard / menu / gameplay handling.
Similarly, Lucky 13 is another good example of making games in Python, though it uses quite a different coding style / conventions and will probably require quite a bit of research to fully understand what is happening.
Finally, the only other thing coming to mind is Arcade, another project of mine. This is quite complex especially for when you are just starting out. It also is currently being updated, so there is that too. Comments are brief--it's mostly a public experiment. I think it's a good candidate for showing how to save state. We're using JSON instead of Pickle (long story) so verifying that we got what we expect can get... fun, but again, I believe in seeing both what you should and should not do. If this makes you be permanently in favor of Pickle then so be it. I wouldn't be able to say you were entirely wrong, either. Arcade is also the only example on the list demonstrating any form of compilation, a question that you will undoubtedly have at some point in time. It uses Nuitka, but you can easily switch it to use Pyinstaller, though cythonizing would be another matter.
Also, it should be noted that you have different options for what to use when creating games. Pygame, Pyglet, Panda3D... the choice is up to you. Pygame seems to be the popular contender and so you would likely be able to receive quicker help, but it's not like the others will leave you hanging. Okay--maybe some would--but you would actually have to try and find something arcaic.
Hope this helps.

2022-01-25 00:55:41

Its would be helpful if you have a good understanding of various data structures, such as functions, classes, variables, lists, etc. I've made a few posts before demonstrating things like interactive menu's, A-star pathfinding, and maps, which are generally the things you'd need for a game engine, even posted a copy of one of my procedural map generation algorithms.

For a basic menu/game structure you can follow something like [this]:

import pygame
import sys

class main(object):
    def __init__(self):
    #initialize pygame
        pygame.init()
    #create display
        self.window = pygame.display.set_mode([640,480])
    #current menu state
        self.state = 'title'
    #list of menu/game classes
        self.menus = {'title':titlescreen(), 'game':game()}

    #primary update loop
        while True:
        #check for key press events
            for event in pygame.event.get():
                if event.type == pygame.KEYDOWN:
                    key = event
                else:
                    key = None

        #update and pass key presses and menu state to active menu
            self.state = self.menus[self.state].update(key,self.state)

        #update window
            pygame.display.update()


#titlescreen menu class
class titlescreen(object):
    def __init__(self):
    #menu option
        self.option = 0

    def update(self,event,state):
    #if a key has been pressed
        if event != None:
        #move up in the menu
            if event.key == pygame.K_UP:
                if self.option > 0:
                    print(self.option)
                    self.option -= 1

        #move down in the menu
            elif event.key == pygame.K_DOWN:
                if self.option < 1:
                    print(self.option)
                    self.option += 1

        #select a menu option
            elif event.key == pygame.K_RETURN:
            #if option is 0 return game state and play tone
                if self.option == 0:
                    print('game menu')
                    return 'game'
            #quit game
                elif self.option == 1:
                    print('quit')
                    pygame.quit()
                    sys.exit(0)

    #return current state if no changes
        return state


#main game class
class game(object):
    def __init__(self):
        pass

#DEMO: return to titlescreen
    def update(self,key,state):
        return 'title'


a = main()

For your game class you'd probably want a 2D grid list for your map, separate player/enemy classes for populating the map and moving around/interacting with things, etc. There's a lot of things to cover, but if you have any questions along the way with wherever you happen to go, feel free to ask.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2022-01-25 01:26:26

I suppose that Everdark Clash renders the previous attempt with Pygame pointless, so maybe I should upload the source to that? ... But I fear that would be discouragingly nightmarish to try and read, even before getting to all the design flaws. hmm
It was sorta-kinda playable. Menus worked but were incomplete, and you could run around and combo enemies. That's about it.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2022-01-25 12:07:08 (edited by Leos 2022-01-25 12:09:12)

I am looking into arcade (a python package) that does 2d games. Trying to see how good that is.
What i done wit hmenus is using a class and inherent from the default View class from the package which has on_keyDown, key up, etc functions. so i have a list of menu options, and check if enter, up or down a key is press and trigger the function if any is passed in.

End of Post!
Leos signing off.
CFN ID: LeosKhai. (Always looking to fight people)
Discord: leos_khai

2022-01-25 17:28:03

@1: if you have experience with terminal based stuff, you can make the game have a tui interface, for example the menu can be made with some careful use of curses in such a way menu items are actually read, etc. For sound, you can use synthizer no problem, though I heard the python bindings are deprecated and will remain on an older version of the library for an indeterminate amount of time, but the things it supports should be good enough. Plus, since you are rendering the game with tui mode, you can add ascii art and all that, so the sighted don't lose their way while in the map I think. The map rendering can, for example, be disabled from some kind of options menu, in case the screenreader announcing all sorts of characters isn't desirable which it isn't in most cases, so perhaps the game would have to come with it disabled. Many people are underestimating the power a tui can still have, especially for roguelikes since it seemns from your post that's kinda what you want to do, but I think such interfaces, if desined right, can be used still for audiogames, as well as providing some kind of visual input for sighted or partially sighted players. So yeah, I don't think there's much need to use pygame, a terminal can give you information about keypresses and so on, plus it's more along the level of what you know, so I'd say go for it in this form even, no need to learn something like pygame yet, plus most of the game logic is transferable though, even if you want later to migrate to pygame or another game framework like that.

2022-01-25 18:33:40

I still upgrade the library, as long as doing so isn't going to take significant effort.  I don't add new features.  I'm open to contributions, as I've said many times before.

My Blog
Twitter: @ajhicks1992

2022-01-25 19:38:00

Hay guys, thanks for the responses and suggestions. @3, I’ll be definitely having a look through those links, cause I think that seeing some actual code in action should give me a better perspective of how things actually work in principle.
@8, funnily enough, originally I was actually playing around with the concept of making a sort of Rim World-like terminal game. Think a rogue-like text based Fallout in space, but a lot crappier given that I had no clue at the time, or pretty much even nowadays, of any moderately decent practices. I could always go back to it, and a rogue-like is most definitely going to be on the cards for the future given that I love the hell out of them, but for now, I’d rather go for a tactical battle-like interface. Honestly, what got me genuinely motivated to try and do something like this is from watching somebody play fallout tactics which, whilst a mediocre game at best, had some concepts which I’d love to have seen in an audio game. Obviously this is a goal of mine for future me to tackle, after I’ve created some dummy programs and slowly improve my piss quality skills, but I’m going to try and work off of the notion that nobody’s going to whip out the game that I’d love to have created, so I may as well role up my sleeves whilst I’m still 16 and motivated to throw myself at a completely unprofitable pursuit such as audio game creation, and try. Even if it’s a heaping mound of trash, at least I’ll have learned something.

Hit up my YouTube Channel at
https://www.youtube.com/channel/UCC9wWO … R85ILY1VQ/
Their you'll find some gaming videos, and what ever els my confused mess of a brain decides to upload. Hope you enjoy it and Stay safe, folks.

2022-01-26 13:22:51

How about server/client networking code? is there a good game example? on how to handle those events.

End of Post!
Leos signing off.
CFN ID: LeosKhai. (Always looking to fight people)
Discord: leos_khai

2022-01-26 13:43:00

Nope, there aren't

best regards
never give up on what ever you are doing.

2022-01-26 13:52:24

@11
Forget about that for a while. People should stop jumping onto networking when starting to learn coding, Networking is complicated.

2022-01-26 14:07:08

@11, no, there isn’t. Networking is unique to each project and is extremely complicated to get right in the best case scenario. Though not focused on it directly, Sound RTS has some stuff to look into, but that is about it

2022-01-26 19:28:43

the thing about networking is that almost no one in this community can do it right.  That possibly includes me and I've been coding for 10 years (time will tell. I think I am. That doesn't mean I am...).  Sending packets around isn't your problem, handling them is, and that can be as big as many new programmer games if not larger.

My Blog
Twitter: @ajhicks1992

2022-01-26 19:41:13

@11
Networking itself isn't too difficult, i've posted an example of python twisted in a gaming context before [here]. The hard part is making it reliable and/or secure, with things like compensating for packet loss, high ping, desynchronization, packet and network security and design, etc. Some security models are more demanding than others, and ultimately nothing is 100% secure, so how hard/far you want to take it beyond something like LAN play or a server list is up to you.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2022-01-27 07:11:13 (edited by Leos 2022-01-27 07:11:55)

@13, I know that, i am getting reference materials together.
@14, thanks, every little helps.
@15, No doubt, it sounds complicated.
@16 thanks.

Yeah, i want to prepare myself with all useful example/guides before I get stuck in the middle and didn't have thing plan out.

Never been a fan of just slowly programming pieces and modifying it over and over.

End of Post!
Leos signing off.
CFN ID: LeosKhai. (Always looking to fight people)
Discord: leos_khai

2022-01-27 09:29:11

@17
Hm, well if your interested in reference material there's a bunch around, like [1500 Archers] and such. Depending on what you have in mind more articles/info could be pulled up, different types of games often require different network models, like FPS or RTS. You should always plan from the beginning on what kind of network model you'll be using as implementing it later can mean refactoring a lot of code. When synchronizing clients or data, be sure to stick with deterministic data types for game state data, IE: No floating point numbers, as they can slightly vary between machines and desynchronize your simulation. You may also want to look into the differences between TCP/IP and UDP protocols, asyncio, and sockets, etc.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2022-01-27 17:28:16

For what it's worth, Twisted is no longer really used in new projects and newer things like asyncio will give you a much better time.

My Blog
Twitter: @ajhicks1992

2022-01-29 18:21:21

Leos wrote:

How about server/client networking code? is there a good game example? on how to handle those events.

There is Quake 3. It's not an audio game and it's not written in Python but that's not a problem.
https://fabiensanglard.net/quake3/The%2 … 0Mode.html
https://fabiensanglard.net/quake3/network.php
https://github.com/id-Software/Quake-III-Arena

2022-01-29 23:21:53

Hay folks, so after nosing through the provided examples and digging around on the internet, I’ve started experimenting with adding sounds and taking keyboard input. The sounds area is going pretty well, figuring that out step by step, but I’m getting stuck on trying to figure out how to take keyboard commands. The program doesn’t throw up an error, but hitting enter doesn’t do anything. Can anybody smarter and more perceptive than me figure out why this isn’t working as it should.
# import all the needed modules
import os
import random
import time
import sys
import pygame
from random import randint
from pygame import *
pygame.init()
from pygame import mixer
pygame.mixer.init()
With = 500
Hight = 400

DISPLAYSURF = pygame.display.set_mode((With, Hight))
pygame.display.set_caption("Soler Bound")
def Main01():
    Voice0 = pygame.mixer.Sound("Sounds\Voice\Main\Menu-00.wav")
    pygame.mixer.music.load("Sounds\Music\Main.ogg")
    pygame.time.delay(1000)
    pygame.mixer.music.set_volume(0.03)
    pygame.mixer.music.play(-1)
    pygame.time.delay(1500)
    Voice0.play()
    import Sounds
    pygame.time.delay(6000)
    Sounds.Voice1.play()
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_RETURN:
                Sounds.Menu1.play()
Main01()
Running = True
while Running:
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()
pygame.display.update()

Hit up my YouTube Channel at
https://www.youtube.com/channel/UCC9wWO … R85ILY1VQ/
Their you'll find some gaming videos, and what ever els my confused mess of a brain decides to upload. Hope you enjoy it and Stay safe, folks.

2022-01-30 01:15:46

@21
The problem is Main01(). What your using is a function, and functions are strictly "one and done" types, so you call Main01() once, there are no loops in it, it runs once, and then it ends. After that you run a loop and check if the game quits, but thats all you check for. You should restructure your use of that function, or consider uses classes. I posted a menu example above that may help with this, its useful to have a central update loop and swap between different classes/states. In this particular case, you might want to move your keyboard commands into your loop:

Running = True
while Running:
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_RETURN:
                Sounds.Menu1.play()
        if event.type == QUIT:
            pygame.quit()
            sys.exit()
pygame.display.update()
-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2022-01-30 01:48:52

You might also need something like "time.sleep(0.01)" in the while loop to avoid 100% CPU usage.

Running = True
while Running:
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_RETURN:
                Sounds.Menu1.play()
        if event.type == QUIT:
            pygame.quit()
            sys.exit()
    pygame.display.update()
    time.sleep(0.01)