2d-games

Pygame: What is the best way to display these ships and their movement from sprite sheet?

与世无争的帅哥 提交于 2021-02-08 07:37:23
问题 Attached below is one of the sprite sheets I am using. Right now, I am wondering the best way to display the ships with their animation when moving. The ships have 9 frames. I have found old examples with deprecated code, or examples that have you break the images into individual files. I would love for someone to show me the best way to use these sprites as they are. Thank you for your time. 回答1: What is the best way can't be answered, because in the end that's subjective; and depends on

How to make an object move in the path of an arc?

こ雲淡風輕ζ 提交于 2021-02-04 14:12:33
问题 I'm making a game where there should be a robot throwing ball-shaped objects at another robot. The balls thrown should fly in the shape of a symmetrical arc. Pretty sure the math-word for this is a parabola. Both robots are on the x axis. How can I implement such a thing in my game? I tried different approaches, none worked. The current system of moving things in my game, is like so: Every object has x and y co-ordinates (variables), and dx and dy variables. Every object has a move() method,

How to simulate Jumping in Pygame for this particular code

百般思念 提交于 2021-01-29 22:10:11
问题 I have been trying to simulate the jump in the Pygame code but haven't been able to successfully implement it. There is a rectangle of dimension 10 by 10 and I want that rectangle to jump when SPACE is press. I am keeping this code independent of gravity for now. import pygame pygame.init() ScreenLenX = 1000 ScreenLenY = 500 win = pygame.display.set_mode((ScreenLenX, ScreenLenY)) pygame.display.set_caption("aman") run = True Xcord = 100 Ycord = 100 length = 10 height = 10 vel = 2 xmove = 1

How to simulate Jumping in Pygame for this particular code

断了今生、忘了曾经 提交于 2021-01-29 21:24:45
问题 I have been trying to simulate the jump in the Pygame code but haven't been able to successfully implement it. There is a rectangle of dimension 10 by 10 and I want that rectangle to jump when SPACE is press. I am keeping this code independent of gravity for now. import pygame pygame.init() ScreenLenX = 1000 ScreenLenY = 500 win = pygame.display.set_mode((ScreenLenX, ScreenLenY)) pygame.display.set_caption("aman") run = True Xcord = 100 Ycord = 100 length = 10 height = 10 vel = 2 xmove = 1

How can i make the enemy go to the character position?

微笑、不失礼 提交于 2021-01-29 07:50:56
问题 What my game has is a character in a preset position in a 2d-game mobile(x=0.33, y=9.48, z=0). I have enemys that are spawn from different angles of the screen with a movement script. But i have to modify the script so it moves towards the character position always. Tried to set the position of the enemy = with character position. but that doesnt work. Anyone has any idea how can i do that? here is the script: /// //Speed - essential : true ? let speed; let enabled = false; let phys; function

Create a basic 2D platformer game in Unity

做~自己de王妃 提交于 2021-01-17 09:14:06
问题 I know very little Unity and would like to create a platform 2D game very simple, just using the basic shapes (squares, rectangles, circles, etc.). I searched the internet and I found a more complicated tutorial of what I need. For example, I saw this but its goal is more ambitious than mine (I have also seen other tutorials but I can't put in additional links). I would love to create something very easy as point to understand the program basics and then try to put something more complicated

Pygame Drawing a Rectangle

心已入冬 提交于 2020-12-02 06:05:06
问题 Im making a game that requires knowing how to draw a rectangle in python 3.2. I have checked lot of sources but none show exactly how to do it. Thanks! 回答1: import pygame, sys from pygame.locals import * def main(): pygame.init() DISPLAY=pygame.display.set_mode((500,400),0,32) WHITE=(255,255,255) BLUE=(0,0,255) DISPLAY.fill(WHITE) pygame.draw.rect(DISPLAY,BLUE,(200,150,100,50)) while True: for event in pygame.event.get(): if event.type==QUIT: pygame.quit() sys.exit() pygame.display.update()

Pygame Drawing a Rectangle

早过忘川 提交于 2020-12-02 06:00:48
问题 Im making a game that requires knowing how to draw a rectangle in python 3.2. I have checked lot of sources but none show exactly how to do it. Thanks! 回答1: import pygame, sys from pygame.locals import * def main(): pygame.init() DISPLAY=pygame.display.set_mode((500,400),0,32) WHITE=(255,255,255) BLUE=(0,0,255) DISPLAY.fill(WHITE) pygame.draw.rect(DISPLAY,BLUE,(200,150,100,50)) while True: for event in pygame.event.get(): if event.type==QUIT: pygame.quit() sys.exit() pygame.display.update()

Pygame Drawing a Rectangle

拟墨画扇 提交于 2020-12-02 06:00:22
问题 Im making a game that requires knowing how to draw a rectangle in python 3.2. I have checked lot of sources but none show exactly how to do it. Thanks! 回答1: import pygame, sys from pygame.locals import * def main(): pygame.init() DISPLAY=pygame.display.set_mode((500,400),0,32) WHITE=(255,255,255) BLUE=(0,0,255) DISPLAY.fill(WHITE) pygame.draw.rect(DISPLAY,BLUE,(200,150,100,50)) while True: for event in pygame.event.get(): if event.type==QUIT: pygame.quit() sys.exit() pygame.display.update()