Progress - QueenChristina/Neverending-Dream-RPG-in-Python GitHub Wiki
May:
β Took a break to start and finish Calculus Zombies, implementing the basic structure constructed so far here. It worked out well, just needs polish and depth (was still somewhat spaghetti code): https://github.com/QueenChristina/Calculus-Zombies.
4/28/19:
β Perfected preventing sprite overlap with rectangle attributes to sprite by making Player unable to pass over another sprite, and the sprite unable to pass over player (even when both sprite and Player are moving). Also made correct rendering of sprites in layers based on their y position.
β Red boxes rendered are the rectangles that cannot be overlapped, green rectangles are the area in which the player can interact with the sprite with a mouse click or space key.
def drawSprites(spriteslist): orderedList = sorted(spriteslist, key = lambda a: a.rect.bottom) pygame.sprite.Group(orderedList).draw(DISPLAY)
4/24/19:
β Finally figured out how to do collision detection with pygame.sprite.spritecollide(self, group, False) (returns list of collided sprites in the group) and pygame.sprite.collide_rect(Sprite.Player, Sprite.objPerson) (returns bool if True or False). May try using collide_mask(SpriteLeft, SpriteRight) -> point, pygame.sprite.groupcollide(), pygame.sprite.spritecollideany() sometime.
Trying https://www.pygame.org/docs/ref/mask.html and http://renesd.blogspot.com/2017/03/pixel-perfect-collision-detection-in.html for pixel perfect collision detection next.
4/18/19:
β Split up my original file into multiple files by module to make reading the code easier. Starting to combine the animations and original rpg features together; can animate or loop background characters or objects while also allowing the player to move around by arrow keys. Fixed a small issue with self.changeimage()'s index being out of range due to frame not changing to current direction's animation sequence.
4/12/19:
β Streamlined movement to allow for BOTH looped and one-time-animation movements to points with just one function. Points can now also be moved IN SUCCESSION with just ONE LINE. Each directional movement also corresponds to a certain corresponding animation ex. if the object is moving right, the walk sequence for it moving right plays. This will be useful for enemy animations later on and automated pathways.
I'm very proud of how easy it will be to implement these animations (JUST ONE LINE!), though the base-code itself can be cleaned up and be more efficient, which I will try to do in the future.
self.moveto(dx, dy, [points_to_get_to], loop?) For example: objPerson.moveto(4, 4, [(50,5), (300, 5), (300, 300), (50, 300)], False)
4/10/19:
β Made movement for sprites, which can be animated too. Different kinds of movement include specifying a point the sprite moves to (multiple points can be designated in succession), moving forever in one direction, and moving back and forth forever. Difficulties included being able to make a sprite move in one direction to a point, and then moving to another point ONLY when previous point has been done with. This was hard as Pygame works with a game loop, so one function in the loop would be called continuously. Very happy I was able to make this work, and now I can just call self.moveto((x,y)) for a sprite to move to a point ONLY when it has finished moving to previous points with just ONE LINE. This will be helpful is I have to animate a scene and sprite move onscreen, with minimal coding of the actual movement.
I can also just play through an animation once (will be helpful for a cool logo at the beginning or an animated scene), though Python is a bit too slow for my taste when handling the frame rate of displaying very large sized pictures.
3/14/19:
β Created a class for inanimate objects, which each have a text box that pops up (with the animated text) when the player is near the object and pressing either the space key or clicking the mouse. Player can interact with bed, food bowls, fridge, and calendar, each with a unique description.
3/3/19:
β Rendered font animation (one character at a time)with for loop only once by space key or mouse down, and set different frames to be shown of player depending on last direction. Planning to optimize this code more later on.
def message(text): global currentframe, text_finished small_font = pygame.font.Font("PixelFont.ttf", 35) text_surface = small_font.render(text, False, (255, 255, 255)) text_box = pygame.image.load('Text Box.png') text_box = pygame.transform.scale(text_box, (DISPLAY_X-10, int(DISPLAY_Y/3))) DISPLAY.blit(text_box, (0, int(2*DISPLAY_Y/3))) print_text = '' start_time = pygame.time.get_ticks() if text_finished == False: for i in text: print_text += i text_surface = small_font.render(print_text, False, (255, 255, 255)) DISPLAY.blit(text_surface, (int(DISPLAY_X/18), int(2.2*DISPLAY_Y/3))) text_rect = text_surface.get_rect() pygame.display.update() pygame.time.wait(10) if print_text == text: text_finished = True elif text_finished == True: text_surface = small_font.render(text, False, (255, 255, 255)) DISPLAY.blit(text_surface, (int(DISPLAY_X/18), int(2.2*DISPLAY_Y/3))) pass
2/26/19:
β Created my own font and rendered font to screen in text box once space key is pressed.
2/22/19:
β Created functions that defined obstacles that are impassable to the player, which can be used to draw multiple obstacles in one scene. Done so that I can add as many obstacles as I want in one room with just one line.
2/16/19:
β Made player walking animation for front, back, and side, which runs with the arrow or WASD keys. Boundaries have been set so that the player canβt walk off the map. Drawings of objects in room such as calendar, fridge, and cat bowls have been made. Sound such as footsteps plays when player moves and clock ticking background music is set to loop.
β Next: objects into obstacles, interactable objects with text boxes, and camera movement.
β For now, my goal is to finish making a trash RPG to learn all about Pygame focusing on functionality rather than art or story. After that, I will remake the RPG while focusing on art, aesthetics, and story.
2/11/19:
β Made sprite move with 8 directions and have footstep sounds as well as walking animation play when moving. Background sound loops forever. The Pygame RPG journey begins!
β New updates coming soon! Let me know if you're interested.