# Search the Community

Showing results for tags 'Python'.

• ### Search By Tags

Type tags separated by commas.

### Categories

• Audio
• Music and Sound FX
• Career Development
• Production and Management
• Game Design
• Game Design and Theory
• Writing for Games
• UX for Games
• Industry
• Interviews
• Event Coverage
• Programming
• Artificial Intelligence
• General and Gameplay Programming
• Graphics and GPU Programming
• Engines and Middleware
• Math and Physics
• Networking and Multiplayer
• Visual Arts
• Archive

• News

• Audio
• Visual Arts
• Programming
• Writing

### Categories

• GameDev Unboxed

### Categories

• Game Developers Conference
• GDC 2017
• GDC 2018
• Power-Up Digital Games Conference
• PDGC I: Words of Wisdom
• PDGC II: The Devs Strike Back
• PDGC III: Syntax Error

### Forums

• Audio
• Music and Sound FX
• Games Career Development
• Production and Management
• Game Design
• Game Design and Theory
• Writing for Games
• Programming
• Artificial Intelligence
• Engines and Middleware
• General and Gameplay Programming
• Graphics and GPU Programming
• Math and Physics
• Networking and Multiplayer
• Visual Arts
• 2D and 3D Art
• Critique and Feedback
• Topical
• Virtual and Augmented Reality
• News
• Community
• GameDev Challenges
• For Beginners
• GDNet+ Member Forum
• GDNet Lounge
• GDNet Comments, Suggestions, and Ideas
• Coding Horrors
• Hobby Project Classifieds
• Indie Showcase
• Article Writing
• Affiliates
• NeHe Productions
• AngelCode
• Workshops
• C# Workshop
• CPP Workshop
• Freehand Drawing Workshop
• Hands-On Interactive Game Development
• SICP Workshop
• XNA 4.0 Workshop
• Archive
• Topical
• Affiliates
• Contests
• Technical
• GameDev Challenges's Topics

### Calendars

• Community Calendar
• Games Industry Events
• Game Jams

• Members

• 0 Replies

• 0 Reviews

• 0 Views

Found 34 results

2. ## Python Announcing AppGameKit for Python!

Hello all, I have teamed up with TheGameCreators for them to trial a Python version of AppGameKit in the form of a PYD file that makes AppGameKit commands available to Python 3.6 and greater. Currently this PYD is compiled only for use with the Windows x86 version of Python. It is a free, unlimited version of their commercial product, but it does show the AppGameKit logo for a few seconds on game startup and AppGameKit is mentioned in the window title when in windowed mode. The PYD works with PyInstaller for easy distribution. If you haven't heard of AppGameKit, I would recommend looking over their website. They also have documentation online and an active community forum. I should point out that method names have been changed to follow PEP 8 naming conventions, so they will be similar but different from the online help. I also had to make a few changes mentioned on the project's itch.io page. There is also a PYI file there that can be used with PyCharm for easier access to the same information. As mentioned, this is a trial for them, but if there's a positive response they will extend the project and include a way of compiling an executable without the intro logo and window title text as well as support other OS. Please take a look and feel free to ask me any questions about it here or on the project's community forum on itch.io. AppGameKit for Python project page at itch.io: https://fascimania.itch.io/appgamekit-for-python Original announcement url: https://www.thegamecreators.com/post/announcing-appgamekit-for-python
3. ## 2D Random Map Generation

I want to make a random map generator in python 3, but I have no idea how to do it. Could someone recommend me a good starting point? What I want to make is a flat 2D overworld-map with roads, rivers, settlements, farmlands, forests, and plains. I don't want to model specific buildings. This is just for a game I'm making where I'd like the player to be able to travel from point to point.
4. ## my first program in python

I wrote my first program (not including the false start last time I attempted programming) in Python... and it works! after a few bug fixes it's actually quite small and some would think insignificant. But I'm getting used to the syntax and form of the language. print ("hello") print ("nwhat are your 2 favourite foods of all time?") food1 = input ("nt1.") food2 = input ("nt2.") print ("I have made ",food2+food1," for you!") input ("press a key to exit and enjoy your meal :)")
5. ## my 2nd program in python

tip15 = 0 tip20 = 0 price = input ("how much did your meal cost?") tip15 = int (price) * .15 tip20 = int (price) * .2 print ("A 20% tip would be ",tip20," and a 15% tip would be",tip15) input () I wrote a tipper program for an exercise. It's a simple program and it took 20mins to write including several bug fixes, where I had to go back to looking through the textbook and a few glances at my first program, before I got it running properly. I made the usual noob mistakes - since I've tackled many different languages, I had to figure out if I needed to declare variables. I also got the variable on the wrong side of the equals sign, then I forgot to include commas in my print statement for the variables. I also forgot to state that the variable was an integer. Finally, I forgot to use brackets and then incorrectly included the calculation inside the brackets. Eventually, I figured all of this out and came up with the above seemingly simple program. And it works! I'm still not using comments, but I'll fix that when I start writing longer programs.
6. ## an early coding exercise 1

carPrice = input ("what is the base price of the car?") tax = int (carPrice) * .125 insurance = 250 totalcarPrice = int (carPrice) + int (insurance) + int (tax) print ("total cost of your car including: insurance $",insurance,",") print ("and tax:$",tax," comes to $",totalcarPrice) input () This is a program that figures out all your extra costs, when buying a car. The only mistake I still need to figure out, is what the escape clause is for avoiding having a space at the end of a statement inside a print function. It works fine, the user enters the base cost for the car. Program calculates the tax and adds a previously decided insurance cost. Then the program provides the user with both the individual costs, and the total all-inclusive price of the car. EDIT: After some research not in-book, it turns out that you can avoid the white spaces in between statements by using the function sep = "", which should be treated as a variable - so not inside the quotation marks of the print function, rather, naked inside the brackets. So the final program now looks like this: carPrice = input ("what is the base price of the car?") tax = int (carPrice) * .125 insurance = 250 totalcarPrice = int (carPrice) + int (insurance) + int (tax) print ("total cost of your car including: insurance$",insurance,",", sep = "") print ("and tax: $",tax," comes to$",totalcarPrice, sep = "") input ()
7. ## a fortune cookie program

So it took one day to write and bug fix. Then another day to go through guesswork and figuring it out - to get the program to work. I haven't got up to while loops in the book, so it took a while - a few errors before I got it working. And I certainly haven't got as far as def methods, so using them was difficult and problematic. But I wanted my program to be complete with an exit option. import random def end_game(): end_message = ("game over") print (end_message) def game(): againPlay = "y" while againPlay == "y": nmCookie = random.randrange(5) begin = input ("cookie time, open your fortune cookie") if nmCookie < 1: print ("you are going to die someday") againPlay = input ("Still hungry") elif nmCookie == 1: print ("you just ate a cookie") againPlay = input ("Still hungry") elif nmCookie == 2: print ("you are going to eat another cookie") againPlay = input ("Still hungry") elif nmCookie == 3: print ("you like cookies") againPlay = input ("Still hungry") elif nmCookie == 4: print ("you will have a gargantuan legacy") againPlay = input ("Still hungry") else: end_game() game () end_game ()

Hi all, I am starting to develop a tactics game and ran into a problem I had not thought of. I began by drawing a screen with a hex grid, and this is no big deal. I got that working fine. But, I realized it didn't look quite right. This is because in most strategy games, you're not looking straight down. There is a bit of a tilt. Attached is an example of what I mean. The hexagons on bottom are larger than the hexagons on top, and I'm unsure of how to go about adding this effect. Especially when you consider that some maps may be of different sizes. I'm not sure if this is the right place to post something like this, but it seems as though some sort of linear transformation would be applied? No? I don't even know where to begin in a problem like this. Thanks.

10. ## Python Interest in Python

I was looking for a library to make a server/clients program. I was thinking there would be easy tutorials for Javascript or Java. What I ran across that is interesting is a Python tutorial for teens that looks pretty easy. https://www.raywenderlich.com/38732/multiplayer-game-programming-for-teens-with-python I don't know too much about Python though and I am wondering if the language is worthwhile. Is it supported? Also, I am interested in the possible use of a relational database, of which I found : PostgreSQL. If you know Python could you please give me a recommendation. Its future, use, popularity, IDE, Database suggested? From what I see it looks like an understandable language. One of the highly recommended IDEs called Pycharm has no database support, so I stopped here and thought I'd bring it up in this forum. I'm interested in any free versions too, EDIT: Pygame is a download needed : https://www.raywenderlich.com/24252/beginning-game-programming-for-teens-with-python Thank you; maybe you have alternate suggestions? Josheir
11. ## Projectile Dominion: Gameplay 2

From the album MissileCommandChallenge2018

Additional game play from my 2018 Missile Command Challenge Submission
12. ## Projectile Dominion: Game Play

From the album MissileCommandChallenge2018

Game play from my 2018 Missile Command Challenge Submission
13. ## Projectile Dominion: Ending Screen

From the album MissileCommandChallenge2018

The ending screen from my 2018 Missile Command Challenge submission
14. ## Projectile Dominion: Title Screen

From the album MissileCommandChallenge2018

The title screen to my 2018 Missile Command Challenge submission

16. ## Kivy Window Resizing Messes up Screen Formatting

I want to make it so the location and size of the buttons I use are changed to suit the background image when the screen is resized. Here is my code so far: """ Combines various .py files and allows the game to run. """ from kivy.app import App from kivy.uix.image import Image from kivy.config import Config from kivy.uix.button import Button from kivy.uix.floatlayout import FloatLayout class MainMenu(FloatLayout): def __init__(self, **kwargs): super(MainMenu, self).__init__(**kwargs) start_button = Button(pos=(25, 75), background_normal="Start.png", background_down="Start_Down.png", size_hint=(.1, .1)) load_button = Button(pos=(225, 75), background_normal="Load.png", background_down="Load_Down.png", size_hint=(.1, .1)) options_button = Button(pos=(425, 75), background_normal="Options.png", background_down="Options_Down.png", size_hint=(.150, .1)) quit_button = Button(pos=(708, 75), background_normal="Quit.png", background_down="Quit_Down.png", size_hint=(.1, .1)) background = Image(source="Main_Menu.png", pos=(0, 0)) self.add_widget(background) self.add_widget(start_button) self.add_widget(load_button) self.add_widget(options_button) self.add_widget(quit_button) class BanditKing(App): def build(self): self.title = "Bandit King" self.icon = "Window_Icon.png" return MainMenu() def main(): Config.set("graphics", "width", "1600") Config.set("graphics", "height", "900") Config.write() BanditKing().run() if __name__ == "__main__": main() Here is what it should always look like. Here is what it does: You might be able to tell the "Options" button is slightly off line with the other buttons. I would also like to know how to fix that.
17. ## SAT not working properly

Here is my implementation of SAT, it does not work properly as the title says, in that it quite frequently registers a collision when there is not one, can you check and see if there is anything blatantly wrong with the code? Thanks. I have my own custom vector class, and poly class. normals = self.normals isCollision = [] MTVs = [] for i in other.normals: normals.append(i) for j in normals: selfProj = [] otherProj = [] for k in self.vertices: selfProj.append(j * k) for l in other.vertices: otherProj.append(j * l) minS = min(selfProj) maxS = max(selfProj) minO = min(otherProj) maxO = max(otherProj) if (minS > maxO or minO > maxS): """No collision on THIS axis""" isCollision.append(False) else: isCollision.append(True) MTVmag = min(maxO - minS, maxS - minO) MTV = j * MTVmag MTVs.append(MTV) if (all(x == True for x in isCollision)): vectorMags = [] for m in MTVs: vectorMags.append(m.magSquared) actMTV = MTVs[vectorMags.index(min(vectorMags))] """Finds the MTV with the smallest magnitude""" indexOfNorm = MTVs.index(actMTV) CN = normals[indexOfNorm] """CN = Collision Normal RETURN [CN, 0] for now, the 0 is a placeholder for the collision point""" if(actMTV.y >= 0 and other.pos.y > self.pos.y): self.translate(actMTV * -0.4) other.translate(actMTV * 0.4) return [CN, 0] elif (actMTV.y >= 0 and other.pos.y < self.pos.y): self.translate(actMTV * 0.4) other.translate(actMTV * -0.4) return [CN, 0] elif(actMTV.y <= 0 and other.pos.y > self.pos.y): self.translate(actMTV * 0.4) other.translate(actMTV * -0.4) return [CN, 0] elif (actMTV.y <= 0 and other.pos.y < self.pos.y): self.translate(actMTV * -0.4) other.translate(actMTV * 0.4) return [CN, 0]
18. ## Circle-Circle impulse resolution not working properly

I am doing a little physics project with circle circle collisions for now, and have tried to do impulse resolution for collisions with 2 circles, using the following code. relativeVelocity = (other.doVerletVelocity()).subtract(self.doVerletVelocity()) normDirecVel = relativeVelocity.dotProduct(collisionNormal) restitution = -1 - min(self.restitution, other.restitution) numerator = normDirecVel * restitution impulseScalar = numerator / float(1 / self.mass) + float(1 / other.mass) selfVel = self.doVerletVelocity() otherVel = other.doVerletVelocity() impulse = collisionNormal.scalarMult(impulseScalar) selfDV = impulse.scalarMult(1 / self.mass) otherDV = impulse.scalarMult(1 / other.mass) newSelfVel = selfVel.subtract(selfDV) newOtherVel = otherVel.add(otherDV) self.oldPos = (self.center).subtract(newSelfVel.scalarMult(dt)) other.oldPos = (other.center).subtract(newOtherVel.scalarMult(dt)) The problem seems to be that whatever value I give to self.mass and other.mass, the output stays exactly the same, the values that I used are: center = Vector(0, 0) radius = 1 oldPos = Vector(0, 0) accel = Vector(0, 0) mass = 100 restitution = 0.001 center2 = Vector(0, 3.20) radius2 = 1 oldPos2 = Vector(0, 3.201) accel2 = Vector(0, -1) mass2 = 1 restitution2 = 1 the output was: 0.0 0.0 0.0 2.165000000000114 0.0 0.0 0.0 2.1360000000001174 0.0 0.0 0.0 2.1066000000001206 0.0 0.0 0.0 2.076800000000124 0.0 0.0 0.0 2.046600000000127 0.0 0.0 0.0 2.0160000000001306 0.0 0.0 0.0 1.985000000000134 CIRCLE INTERSECTION 0.0 -1.985000000000134 0.0 3.938600000000271 0.0 -3.970000000000268 0.0 5.891800000000408 0.0 -5.9550000000004015 0.0 7.844600000000544 0.0 -7.940000000000535 0.0 9.797000000000681 I changed the values for the masses to make them higher, bu the output still remained the same, if you could get to the bottom of this, it would be much appreciated.
19. ## Applying Impulse

I have a circle class which has the following attributes: center, radius, old position, acceleration, mass, and restitution. I then apply impulse resolution as per this link: https://gamedevelopment.tutsplus.com/tutorials/how-to-create-a-custom-2d-physics-engine-the-basics-and-impulse-resolution--gamedev-6331. Here is the code, implementing that, along with my velocity verlet implementation (this is necessary as it explains why I change the values of the old positions of the circles near the end of the impulseScalar method): def doVerletPosition(self): diffPos = (self.center).subtract(self.oldPos) aggregatePos = diffPos.add(self.center) ATT = (self.accel).scalarMult(dt**2) e = ATT.add(aggregatePos) return e def doVerletVelocity(self): deltaD = ((self.center).subtract(self.oldPos)) return deltaD.scalarMult(1/dt) def impulseScalar(self,other): isCollision = self.collisionDetection(other) collisionNormal = isCollision[0] if(isCollision[1] == True): relativeVelocity = (other.doVerletVelocity()).subtract(self.doVerletVelocity()) normDirecVel = relativeVelocity.dotProduct(collisionNormal) restitution = -1-(min(self.restitution,other.restitution)) numerator = restitution * normDirecVel impulseScalar = numerator/(self.invMass + other.invMass) impulse = collisionNormal.scalarMult(impulseScalar) selfVel = (self.doVerletVelocity()) otherVel = other.doVerletVelocity() selfVelDiff = impulse.scalarMult(self.invMass) otherVelDiff = impulse.scalarMult(other.invMass) selfVel = selfVel.subtract(selfVelDiff) otherVel = otherVel.subtract(otherVelDiff) self.oldPos = (self.center).subtract(selfVel) other.oldPos = (other.center).subtract(otherVel) It would help if you accepted the vector methods as correct on face value, and I think that they are named well enough to allow you to figure out what they do, however I can paste them in aswell. My main problem is that when I run this, it registers that a collision has happened, yet the values position of the second circle do not change. How would I go about fixing this, as it seems that I am implementing the calculations correctly. The values of the first and second circle is: center = Vector(0,0) radius = 3 oldPos = Vector(0,0) accel = Vector(0,0) mass = 1 restitution = 0.5 center2 = Vector(0,4.2) radius2 = 1 oldPos2 = Vector(0,4.21) accel2 = Vector(0,-1) mass2 = 1 restitution2 = 0.7 What it returns is here: (it returns the position of the centers) 0.0 0.0 0.0 4.1896 0.0 0.0 0.0 4.178800000000001 0.0 0.0 0.0 4.167600000000001 0.0 0.0 0.0 4.1560000000000015 0.0 0.0 0.0 4.144000000000002 0.0 0.0 0.0 4.131600000000002 0.0 0.0 0.0 4.118800000000003 0.0 0.0 0.0 4.1056000000000035 0.0 0.0 0.0 4.092000000000004 0.0 0.0 0.0 4.078000000000005 0.0 0.0 0.0 4.063600000000005 0.0 0.0 0.0 4.048800000000006 0.0 0.0 0.0 4.033600000000007 0.0 0.0 0.0 4.018000000000008 0.0 0.0 0.0 4.002000000000009 0.0 0.0 0.0 3.9856000000000096 INTERSECTION 0.0 0.0 0.0 3.9688000000000105 INTERSECTION 0.0 0.0 0.0 3.9516000000000115 INTERSECTION 0.0 0.0 0.0 3.9340000000000126 So when it prints INTERSECTION, surely, the stationary circle must change position, if the impulseScalar method is correct, (as it seems to be (as it follows what is said on that link). Even if I let it run for longer, the stationary circle still does not move.
20. ## Why its wrong?

Hello I am a beginner in programmin. I just begun with Python. I write a code, but python say "syntax invalid". I use python 3.6.3 and my system is mac. My code: print("Hello, this is a calculator. ") print("Here you can calculate any numbers you need.") # Here I describe for the user, what the program can do. num_1 = input("Write the first number: ") # Here user write the first number for calculating. num_2 = input("Write the second number: ") # Here user write the second number for calculating. operator = input("Write the matematic operator you need: ") # Here the user write the matematic opertator they neee. if operator == '+': print(int(num_1) + (int(num_2)) elif operator == '/': print(int(num_1) / (int(num_2)) elif operator == '-': print(int(num_1) - (int(num_2)) elif operator == '*': print(int(num_1) * (int(num_2)) elif operator == '%': print(float(num_1) % (float(num_2)) elif operator == '**': print(int(num_1) ** (int(num_2)) print("Thank you dear user! ") Thank'!!! calculator.py