Search the Community

Showing results for tags 'Python'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Categories

  • Audio
    • Music and Sound FX
  • Business
    • Business and Law
    • 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

Categories

  • News

Categories

  • Audio
  • Visual Arts
  • Programming
  • Writing

Categories

  • Audio Jobs
  • Business Jobs
  • Game Design Jobs
  • Programming Jobs
  • Visual Arts Jobs

Categories

  • GameDev Unboxed

Forums

  • Audio
    • Music and Sound FX
  • Business
    • Games Career Development
    • Production and Management
    • Games Business and Law
  • 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
    • Your Announcements
    • 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

Calendars

  • Community Calendar
  • Games Industry Events
  • Game Jams

Blogs

There are no results to display.

There are no results to display.

Marker Groups

  • Members

Developers


Group


About Me


Website


Industry Role


Twitter


Github


Twitch


Steam

Found 17 results

  1. 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.
  2. 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.
  3. 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
  4. I wrote Snake in Python 3 using Pygame and was wondering if anyone can do a code review of it? If this is the appropriate fourm to post such a thing? Some things to mention: 1. I realize I could have used a dict in the place of my Segment class, but I decided to go with the class because it looked more clean to me. 2. I used recursion heavily, though I could have used a list instead. I decided to do it recursively for practice and fun (I don't use recursion often). 3. I don't have doc strings for any of my functions. 4. I probably could have used my get_all_snake_segment_locations function to avoid recursion. 5. I set fps to 10 to limit the speed of the game. Is this a bad way to do such a thing? 6. I attached an input manager I created and unit tests for my game for completeness. Though, I'm only asking the actual game to be reviewed, if you want to look at those you can. Also, note the unit tests are not complete yet for several functions I changed. 7. I really appreciate anyone who takes the time to give me feedback of any kind. This fourm has been a huge help to me and I'm grateful for everyone's insight! import sys import random import itertools import pygame import inputmanager class Segment: def __init__(self, rect, direction=None, parent=None, child=None): self.rect = rect self.direction = direction self.parent = parent self.child = child class Game: def __init__(self): pygame.init() self.fps_clock = pygame.time.Clock() self.fps = 10 self.window_size = (640, 480) self.displaysurf = pygame.display.set_mode(self.window_size) pygame.display.set_caption("Snake") self.cell_size = (32, 32) self.start_location = (320, 224) self.head_segment = Segment(pygame.Rect(self.start_location, self.cell_size)) self.up = "up" self.down = "down" self.left = "left" self.right = "right" self.black = (0, 0, 0) self.green = (0, 255, 0) self.red = (255, 0, 0) self.direction = None self.extender = None self.cell_locations = set( itertools.product( range(0, self.window_size[0], self.cell_size[0]), range(0, self.window_size[1], self.cell_size[1]) ) ) def main(self): while True: self.get_input() self.update() self.render() self.fps_clock.tick(self.fps) def get_input(self): inputmanager.InputManager.get_events() inputmanager.InputManager.check_for_quit_event() inputmanager.InputManager.update_keyboard_key_state() inputmanager.InputManager.get_keyboard_input() def update(self): self.handle_input() self.update_snake_direction(self.head_segment, self.direction) self.move_snake(self.head_segment) if self.extender is None: self.add_extender_to_board() if self.head_segment_collided_with_extender(): self.extend_snake() if self.game_over(): self.refresh() def handle_input(self): if inputmanager.InputManager.quit: self.terminate() if (inputmanager.InputManager.keyboard[pygame.K_UP] == inputmanager.InputManager.pressed and self.direction != self.down): self.direction = self.up elif (inputmanager.InputManager.keyboard[pygame.K_DOWN] == inputmanager.InputManager.pressed and self.direction != self.up): self.direction = self.down elif (inputmanager.InputManager.keyboard[pygame.K_LEFT] == inputmanager.InputManager.pressed and self.direction != self.right): self.direction = self.left elif (inputmanager.InputManager.keyboard[pygame.K_RIGHT] == inputmanager.InputManager.pressed and self.direction != self.left): self.direction = self.right def terminate(self): pygame.quit() sys.exit() def update_snake_direction(self, segment, parent_direction): ###TEST if segment.child is not None: self.update_snake_direction(segment.child, parent_direction) if segment.parent is None: segment.direction = parent_direction else: segment.direction = segment.parent.direction def move_snake(self, segment): self.move_segment(segment) if segment.child is not None: self.move_snake(segment.child) def move_segment(self, segment): if segment.direction == self.up: segment.rect.move_ip(0, -self.cell_size[1]) elif segment.direction == self.down: segment.rect.move_ip(0, self.cell_size[1]) elif segment.direction == self.left: segment.rect.move_ip(-self.cell_size[0], 0) elif segment.direction == self.right: segment.rect.move_ip(self.cell_size[0], 0) def add_extender_to_board(self): snake_segments_locations = set(self.get_all_snake_segment_locations(self.head_segment)) location = random.choice(list(self.cell_locations-snake_segments_locations)) self.extender = pygame.Rect(location, self.cell_size) def get_all_snake_segment_locations(self, segment): yield segment.rect.topleft if segment.child is not None: yield from self.get_all_snake_segment_locations(segment.child) def head_segment_collided_with_extender(self): return self.head_segment.rect.colliderect(self.extender) def extend_snake(self): self.extender = None self.add_segment_to_snake(self.head_segment) def add_segment_to_snake(self, segment): if segment.child is None: if segment.direction == self.up: topleft = (segment.rect.x, segment.rect.y+self.cell_size[1]) elif segment.direction == self.down: topleft = (segment.rect.x, segment.rect.y-self.cell_size[1]) elif segment.direction == self.left: topleft = (segment.rect.x+self.cell_size[0], segment.rect.y) elif segment.direction == self.right: topleft = (segment.rect.x-self.cell_size[0], segment.rect.y) segment.child = Segment( pygame.Rect(topleft, self.cell_size), segment.direction, segment ) else: self.add_segment_to_snake(segment.child) def game_over(self): return any([ self.head_segment_collided_with_self(self.head_segment), self.head_segment_out_of_bounds() ]) def head_segment_collided_with_self(self, segment): if segment.child is not None: if self.head_segment.rect.colliderect(segment.child.rect): return True else: return self.head_segment_collided_with_self(segment.child) return False def head_segment_out_of_bounds(self): if (self.head_segment.rect.x < 0 or self.head_segment.rect.y < 0 or self.head_segment.rect.x >= self.window_size[0] or self.head_segment.rect.y >= self.window_size[1]): return True return False def refresh(self): self.head_segment = Segment(pygame.Rect(self.start_location, self.cell_size)) self.direction = None self.extender = None def render(self): self.displaysurf.fill(self.black) self.draw_snake(self.head_segment) if self.extender is not None: self.draw_extender() pygame.display.update() def draw_snake(self, segment): pygame.draw.rect(self.displaysurf, self.green, segment.rect) if segment.child is not None: self.draw_snake(segment.child) def draw_extender(self): pygame.draw.rect(self.displaysurf, self.red, self.extender) if __name__ == "__main__": game = Game() game.main() test_game.py inputmanager.py game.py
  5. I know how to calculate the scalar of the velocity vector after a collision with 2 circles (as per this link: https://gamedevelopment.tutsplus.com/tutorials/how-to-create-a-custom-2d-physics-engine-the-basics-and-impulse-resolution--gamedev-6331) These circles cannot rotate and do not have friction but can have different masses, however I cannot seem to find out any way to find the unit vector that I need to multiply the scalar of velocity by to get the new velocity of the particles after the collision. I also know how to check if 2 circles are colliding. Also, I am only dealing with this in a purely "maths-sense" (ie. the circles have a center and a radius), and would like to know how I can represent these circles on the screen in python 3.0. The vector class: class Vector(): def __init__(self,x,y): self.x = x self.y = y def add(self, newVector): return Vector(self.x+newVector.x, self.y+newVector.y) def subtract(self,newVector): return Vector(self.x-newVector.x, self.y-newVector.y) def equals(self, newVector): return Vector(newVector.x,newVector.y) def scalarMult(self, scalar): return Vector(self.x*scalar, self.y*scalar) def dotProduct(self, newVector): return (self.x*newVector.x)+(self.y*newVector.y def distance(self): return math.sqrt((self.x)**2 +(self.y)**2) The circle class: class Particles(): def __init__(self,currentPos, oldPos, accel, dt,mass, center, radius): self.currentPos = currentPos self.oldPos = oldPos self.accel = accel self.dt = dt self.mass = mass self.center = center self.radius = radius def doVerletPosition(currentPos, oldPos, accel, dt): a = currentPos.subtract(oldPos) b = currentPos.add(a) c = accel.scalarMult(dt) d = c.scalarMult(dt) return d.add(b) def doVerletVelocity(currentPos, oldPos, dt): deltaD = (currentPos.subtract(oldPos)) return deltaD.scalarMult(1/dt) def collisionDetection(self, center, radius): xCenter = (self.radius).xComponent() yCenter = (self.radius).yComponent() xOther = radius.xComponent() yOther = radius.yComponent() if ((xCenter - xOther)**2 + (yCenter-yOther)**2 < (self.radius + radius)**2): return True else: return False I do know about AABBs, but I am only using around 10 particles for now, and AABBs are not necessary now.
  6. Lets say I have a character with a shooting animation that plays every time I hit the space key. I need to block input to assure that the animation finishes before another action is taken. What is a common approach to doing this? Right now, I'm using a variable that is a set to the total number of seconds the animation is. When the variable is zero player input is allowed again. Is there a better way? I'm using Python and Pygame for a 2D game.
  7. Currently, I'm working on recreating connect four for a portfolio of simple games. I'm also writing unit tests for all the code I can. Some of my code functions though only call other functions, or only draw to the screen... #EXAMPLES... def draw_refresh_button_text(self): font = pygame.font.Font(None, 24) text = font.render("Refresh", True, self.black) self.displaysurf.blit( text, ( self.refresh_button_rect.centerx-self.refresh_button_rect.centerx/self.refresh_button_rect.y, self.refresh_button_rect.centery-self.refresh_button_rect.centery/self.refresh_button_rect.x ) ) def draw_disks(self): for column in self.grid: for disk in column: pygame.draw.ellipse(self.displaysurf, disk['color'], disk['rect']) #ONLY CALLS OTHER FUNCTIONS... def get_input(self): inputmanager.InputManager.get_events() inputmanager.InputManager.check_for_quit_event() inputmanager.InputManager.update_keyboard_key_state() inputmanager.InputManager.get_keyboard_input() inputmanager.InputManager.update_mouse_button_state() inputmanager.InputManager.get_mouse_input() How would I go about writing tests for code like this? Should code like this even be tested? Should all code be tested? I'm using the Python unittest module to test. The code here uses Pygame.
  8. My first goal is to build in python a text-based (next version will have graphics) adventure game scenario where a player enters a tavern, and goes on a quest. Earns money, buys weapons and gets in a fight. So I've got four ideas for games I want to build. 1. a space simulation where a mute evolving clique is tasked with colonising planets - it's also a social network. My next goal is to build a 3rd person shooter and streets of rage style framework for a action/adventure game based on my story which is about God's mightiest heroes (with mutation sandbox) versus the devil (read pinhead meets bizarro superman). I also want to build in python, a 3d isometric rpg/sim that looks like the sims 1 but thematically is more like Bully or GTA1, but plays like Hell's Kitchen DS combined with Dofus, with environments combining elements of Phantasy Star, Sonic and art photography of convenience stores, etc. I also want to build an epic adventure story in RPGMakerMV. Any advice as to what else I should build in between to get closer to my goal projects. In a few weeks I'll have my first game, I'm not really sure how to turn it into an executable file so i can share it with people who don't have python installed.
  9. I'm making a multiplayer third person shooter (TPS) game using a Panda3D engine. It's in an early prototype state. A few videos from my DevLog:
  10. Hi, how are you, people who love programming, here I am again after a very long time, I returned to Blender again with my project that I had left aside for personal study, work, etc. This time I want to resort to the help of Python programming experts and GLSL in Blender Game Engine. The first question is? How to make FOG OF WAR in GLSL and Python to a RTS GAME. I am developing an RTS game in UPBGE or BGE. Only I want make a Fog of War System like the game Age of Empires. Do you remember? jajaja Ok Brothers. Everything you konw please help me. I'll be very greatful I will leave pictures of the game I am developing. Regards guys!! https://ibb.co/dyQBPv
  11. Hello! I am currently a student at Aberystwyth University between my 2nd and 3rd years of my BSc in Computer Science. I am currently on an internship year where I am working at Google in London. I've always had an interest in game development and it's something I would very much like to go into once I graduate. I am most proficient in Java and Python, but am also currently learning C++ and Go. I can also do JavaScript and SQL and have experience in using SVN and Git for version control. In terms of game dev experience I have little other than a group project worth 75% of a module for my second year at university where I achieved the highest classification. For the engines I am familiar with I am learning Unity with a view as to learn Unreal at some point in the near future when I feel I have become very competent with Unity. Other than my programming skills I am also able to perform QA and basic business operations for products. I would also consider myself approachable and easy to talk with. I am looking for any kinds of projects currently just to get some experience in game development and am willing to answer any questions that you might have relating to myself or my skills. Thanks in advance, Liam
  12. This function detects if a gameobject has moved or has had its sprite changed. It then calls one of two functions (or none), to draw a piece of the games background over the gameobjects current location or previous location. Should functions like this be avoided? Is this good or bad design? Does it violate SRP? Also, how would something like this be unit tested? #clean up the display... def blit_background_over_dirty_rects(self): for gameobject, data in self.relevant_data.items(): if data['location'] != gameobject.rect.topleft: #gameobject moved... self._blit_background_over_gameobjects_previous_location(gameobject) elif data['sprite'] != gameobject.sprite_manager.current_sprite: #gameobjects sprite changed... self._blit_background_over_gameobjects_current_location(gameobject)
  13. tic-tac-toe review request

    I was looking for an opportunity to learn/improve skills so I wrote this simple Tic-Tac-Toe game. I have written Python code for simple network tests and know enough JavaScript to get by. Still not certain on fine details though, particularly what subtle (or not) best practices I am likely missing. Code review, testing and advice on how to improve would be appreciated. Code is running on PythonAnywhere here: http://coffeeaddict.pythonanywhere.com/tictactoe Code is here on GIT: https://github.com/coffeeaddict19/tictactoe The three pieces are: JavaScript and Markup: tictactoe_page.html Bottle Framework Implementation: tictactoe_bottle.py Python Game Logic: tictactoe_logic.py If you look closely at the game logic the AI is...primitive. Researching MinMax to improve it is the next thing on list but in my experience if I wait for perfection I never get anything done. Anyway...how can I improve this game and this code? Thanks, John
  14. I'm trying to make a game where the characters are randomly generated and retain individual attributes over time. Right now, I'm working on the combat system. I've made it so the roles of "Attacker" and "Defender" will switch between the player character and the NPC they are fighting. Problem is, I'm unsure of how to organize it in an elegant way. All I can think of is doing a bunch of if & else statements every time I need to check. Could you suggest ways of doing this in an elegant way? If there is anything in my code that could be significantly simplified don't be afraid to point that out either. Here is an example of one of the methods I could use help with. In it, I am taking the int type variable, "overall action score", or OAS, from a tuple, which then helps to determine the force of any attacks that land. On if and else statements, I am checking who is attacking, and calling one of their respective physical attributes. def forceFinder(self): """ Determines force of strike from OAS and alacrity. """ #subtract attacker OAS from defender OAS force = self._oasTuple[0] - self._oasTuple[1] #exponentially adds to force according to alacrity and #margin between attacker, and defender OAS. for i in range(0, force, 10): force *= 1.10 if Combat._attacker == "pc": force += Combat._pcAttr["alacrity"] * 3 else: force += Combat._npcAttr["alacrity"] * 3 return int(force)
  15. Here are 3 versions of a method from my inventory class that adds an item to the given inventory (or increases the items quantity). From a Python perspective, which approach would be best? Each method is followed by a sample of how I would use it in practice. I've been pretty interested in code design/architecture lately and I've been trying to get better at Python, so it may seem like a silly question but I'm just curious what you people think. Currently, I'm using approach #1, but I find it misleading that you could add an item and not actually have an item added. And if there's another approach not listed here that would be good please let me know. #1 prevent adding item if is_full(): def add_item(self, item): i = next((i for i in self.items if i.tag == item.tag), None) #Duplicate item... if i is not None: i.quantity += item.quantity elif not self.is_full(): self.items.append(item) player_inventory.add_item(item) #2 throw exception if is_full() and handle outside method: def add_item(self, item): i = next((i for i in self.items if i.tag == item.tag), None) if i is not None: i.quantity += item.quantity elif not self.is_full(): self.items.append(item) else: raise InvetoryFullException("Inventory can only hold 8 items.") try: player_inventory.add_item(item) except InvetoryFullException: pass #3 check if inventory is_full() outside of method: def add_item(self, item): i = next((i for i in self.items if i.tag == item.tag), None) if i is not None: i.quantity += item.quantity else: self.items.append(item) if not player_inventory.is_full(): player_inventory.items.append(item)
  16. Heya everyone! Based on my post score I'm sure you can tell I'm new to this community. I lurked a little bit to get an idea for the community and make sure I didn't post this where it didn't belong. Key Information Language: Python 3.6 Open Source: Yes Level of Programming Knowledge Applied: Beginner-Intermediate ... I use a couple packages and a fair amount of dictionary maintenance that might be daunting to a -brand-spanking-new- newbie. Required Packages: Numpy Git Repo: https://github.com/frawst/pygrid A brief history I'm a Psychology major out of Saskatchewan, Canada, who has always had a profound interest in games. All kinds, from simple pen and paper to the latest video release (Oblivion was like OMG WHAT!?) Anyways, I don't study programming often, I take the occasional Computer Science class just to stay fresh if I haven't been doing much coding lately. I've made a few little games in the past, nothing too spectacular. Space Infaders was my first project when I was 13, and since then I've made a few minor projects in GameMaker, and toyed around with educational text games. The Contemporary I recently realized I have been letting my gaming habits take control of my life, and decided I needed to stop. I've learned about addiction in my education, and part of that education taught me that one addiction must be replaced by another. Apparently that is very true. Since I stopped gaming 3 days ago I have spent nearly 24 hours developing this little text game that I dreamed up nearly 10 years ago after playing a basic little pen and paper game I found on the net. What is my game? My game is a text-based dungeon crawler RPG that runs either in your native command window, or through Python's IDLE interpreter. The recommended method is through a command window since that's where the graphical elements really shine. What's the design philosophy? As of the time I am writing this, there is no real design philosophy. I've made everything I originally dreamed up and have just been adding to it since. I may update this in the future if I decide to take it seriously. Why are you posting this here? To invite criticism. I'm interested in hearing what you guys think about the game, any ideas you might have for expansion, and any other thoughts you might have regarding the game itself. The code is incredibly stringy and I know it needs to be cleaned up, so if you have any direct recommendations for how to structure code like this in a way that is as legible as possible then I am ALL EARS. I know how to read it, and I know where everything is, but when I start thinking about making it easy for others to read I get lost. Furthermore, PEP-8 is not followed in the source at the time I'm writing this which makes things further messier. I will be PEP-ing it soon, I just want to get the FEATURES In there! Furthermore, I also implore any of you who do try the game out and receive inspiration from it to Fork it and make your own additions and customizations! I'd love to see how other people create in the environment that I have built. Alternatively, if you are neither interested in coding or giving feedback, I hope you might at least enjoy playing the game in it's current state! I am updating it at an alarming rate right now as it is in early development, but it is completely playable The only requirements to get started contributing is to have an install of Python 3.6 with the Numpy package installed. python pip install numpy I would post the source code into this thread, but it's around 650 lines of code at the time I am writing this so I'll just have to supply the repo. Repo: https://github.com/frawst/pygrid Thank you in advance for your interest in my little project, and for any and all feedback that you might provide! I hope you enjoy playing the game
  17. I'm working on a 2D top down game in Python with Pygame. I was wondering if it is better to use one large image for a background or individual images? My problem with individual images is when I want to update a portion of the display without updating the entire display. How can I get a subsurface of multiple tiles if the location I need to update is between two tiles? Do I use layered surfaces?