pygame

VSCode Intellisense not Working for pygame

≡放荡痞女 提交于 2021-02-02 09:35:53
问题 While coding in pygame, I realised that VSCode was not showing up itellisense for quite some pygame modules, and instead showed those modules as variables. After some digging, I found out that if you do import pygame.display as display , the intellisense show up just fine. Is there anyway I can use intelliense without importing these modules like this? 回答1: 'Autocomplete and IntelliSense' was provided by Python Server. In vscode, basically you can choose 'Jedi' or 'Microsoft', and they are

Collisions still aren't getting detected in pygame

醉酒当歌 提交于 2021-02-02 09:35:48
问题 I've tried making some of the changes from the other question I had asked, here's the link: Collisions aren't being detected in pygame But anyway, I'm trying to make an asteroids style game, where the asteroids can be destroyed when shot by the player and the ship will be destroyed when hit by an asteroid. The problem is, my collisions aren't being detected at all and they're harmlessly passing through each other. Since people couldn't run my code last time, here are the sprites I'm using:

How do I delete rect object from screen once player collides with it?

≡放荡痞女 提交于 2021-02-02 09:35:28
问题 in draw() function I am trying to delete rect object when player pos = enemy pos but "del" will not work. Any way to delete the enemy object completely? Is there a built in pygame function to delete objects that I don't know about? # draw player def draw(): enemy = pygame.draw.rect(screen, enemy_color, (enemy_x, enemy_y, 25, 25)) player = pygame.draw.rect(screen, player_color, (player_x, player_y, 25, 25)) # if the player is over the enemy then delete the enemy if player_x == enemy_x and

VSCode Intellisense not Working for pygame

大兔子大兔子 提交于 2021-02-02 09:35:07
问题 While coding in pygame, I realised that VSCode was not showing up itellisense for quite some pygame modules, and instead showed those modules as variables. After some digging, I found out that if you do import pygame.display as display , the intellisense show up just fine. Is there anyway I can use intelliense without importing these modules like this? 回答1: 'Autocomplete and IntelliSense' was provided by Python Server. In vscode, basically you can choose 'Jedi' or 'Microsoft', and they are

Collisions still aren't getting detected in pygame

萝らか妹 提交于 2021-02-02 09:33:40
问题 I've tried making some of the changes from the other question I had asked, here's the link: Collisions aren't being detected in pygame But anyway, I'm trying to make an asteroids style game, where the asteroids can be destroyed when shot by the player and the ship will be destroyed when hit by an asteroid. The problem is, my collisions aren't being detected at all and they're harmlessly passing through each other. Since people couldn't run my code last time, here are the sprites I'm using:

Is there a way to restrict the title crawl to certain portion of screen?

做~自己de王妃 提交于 2021-02-02 09:33:33
问题 I am trying do end credits like animation the code above for Title crawl, I am trying to make the following changes to it:- 1) The text should begin at the bottom of screen at certain location, such that no other text from the string should be displayed below that location on the screen. 2) The text should stop at certain location on top of screen such that the line at the top should be deleted as soon as it reaches that location making room for other lines in the string. I am a python newbie

Collisions still aren't getting detected in pygame

家住魔仙堡 提交于 2021-02-02 09:32:02
问题 I've tried making some of the changes from the other question I had asked, here's the link: Collisions aren't being detected in pygame But anyway, I'm trying to make an asteroids style game, where the asteroids can be destroyed when shot by the player and the ship will be destroyed when hit by an asteroid. The problem is, my collisions aren't being detected at all and they're harmlessly passing through each other. Since people couldn't run my code last time, here are the sprites I'm using:

How to make image stay on screen in pygame?

筅森魡賤 提交于 2021-02-02 09:28:12
问题 I am a beginner import pygame as py from math import sqrt, pow nuclear = py.transform.scale(py.image.load('nuclear.png'),(300, 300)) def collosion(enemyX,enemyY,fireX,fireY): distance = sqrt(pow(enemyX - fireX, 2) + pow(fireY - enemyY, 2)) if distance <= 100: return True else: return False collosion1 = collosion(enemy1_x,enemy2_y,shoot1X + 50, shoot1Y + 60) if collosion1: window.blit(nuclear,(enemy1_x,enemy2_y)) enemy1_x = 1400 enemy2_y = 530 shoot1X = tankX shoot1Y = tankY shoot_now = 'not

Overlap between mask and fired beams in Pygame [AI car model vision]

房东的猫 提交于 2021-02-02 08:51:26
问题 I try to implement beam collision detection with a predefined track mask in Pygame. My final goal is to give an AI car model vision to see a track it's riding on: This is my current code where I fire beams to mask and try to find an overlap: import math import sys import pygame as pg RED = (255, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 0, 255) pg.init() beam_surface = pg.Surface((500, 500), pg.SRCALPHA) def draw_beam(surface, angle, pos): # compute beam final point x_dest = 250 + 500 * math.cos

How do you properly implement gravity to a free floating space object and some sort of friction when thrusting in opposite direction

和自甴很熟 提交于 2021-02-02 03:50:26
问题 I am trying to program movement that is basically like Asteroids where once UP button is pressed you accelerate to a certain speed and then because in space you don't stop and can only slow down by thrusting in opposite direction. On top of that, I would like gravity to be pulling you towards the bottom of the screen. I have this accomplished for the most part but the issue I have is: When I turn around and thrust opposite direction, it doesn't slow down first going backwards before starting