小编use*_*231的帖子

在pygame中添加滚动到平台游戏

好的,所以我在下面列出了我的项目的代码,我只是在制作平台游戏时尝试使用pygame.我试图弄清楚如何在玩家之后进行一些非常简单的滚动,因此玩家是相机的中心,它会反弹/跟随他.谁能帮我?

import pygame
from pygame import *

WIN_WIDTH = 800
WIN_HEIGHT = 640
HALF_WIDTH = int(WIN_WIDTH / 2)
HALF_HEIGHT = int(WIN_HEIGHT / 2)

DISPLAY = (WIN_WIDTH, WIN_HEIGHT)
DEPTH = 32
FLAGS = 0
CAMERA_SLACK = 30

def main():
    global cameraX, cameraY
    pygame.init()
    screen = pygame.display.set_mode(DISPLAY, FLAGS, DEPTH)
    pygame.display.set_caption("Use arrows to move!")
    timer = pygame.time.Clock()

    up = down = left = right = running = False
    bg = Surface((32,32))
    bg.convert()
    bg.fill(Color("#000000"))
    entities = pygame.sprite.Group()
    player = Player(32, 32)
    platforms = [] …
Run Code Online (Sandbox Code Playgroud)

python scroll pygame

41
推荐指数
1
解决办法
4万
查看次数

Pygame级别/菜单状态

使用下面的代码,实现游戏状态控制级别的最简单,最简单的方法是什么?如果我想从标题屏幕开始然后加载一个级别,并在完成后继续进入下一级别?如果有人能够解释最简单的方法来解决这个问题就太棒了!

import pygame
from pygame import *

WIN_WIDTH = 1120 - 320
WIN_HEIGHT = 960 - 320
HALF_WIDTH = int(WIN_WIDTH / 2)
HALF_HEIGHT = int(WIN_HEIGHT / 2)

DISPLAY = (WIN_WIDTH, WIN_HEIGHT)
DEPTH = 0
FLAGS = 0
CAMERA_SLACK = 30

def main():
    global level
    pygame.init()
    screen = pygame.display.set_mode(DISPLAY, FLAGS, DEPTH)
    pygame.display.set_caption("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    timer = pygame.time.Clock()
    level = 0

    bg = Surface((32,32))
    bg.convert()
    bg.fill(Color("#0094FF"))

    up = left = right = False
    entities = pygame.sprite.Group()
    player = Player(32, 32)
    enemy = Enemy(32,32)
    platforms …
Run Code Online (Sandbox Code Playgroud)

pygame

11
推荐指数
1
解决办法
3万
查看次数

如何实现粒子引擎

所以我制作了一个吸烟的粒子引擎,我很高兴,我认为它非常适合我的游戏.
我现在需要将它实现到我的游戏中,我遇到了一些麻烦.我想知道是否有人可以解释我将如何在我的游戏中使用我的粒子引擎.
我在下面添加了我的代码(用于冒烟和我的游戏文件).
我希望将粒子与游戏文件分开,但在我的游戏中调用它.
最终,我想在引擎中制作更多粒子效果,我也可以调用它.

有人可以帮忙吗?它可能需要一些调整才能工作.

粒子代码:

import pygame,random
from pygame.locals import *

xmax = 1000    #width of window
ymax = 600     #height of window

class Smoke():
    def __init__(self, startx, starty, col):
        self.x = startx
        self.y = random.randint(0, starty)
        self.col = col
        self.sx = startx
        self.sy = starty

    def move(self):
        if self.y < 0:
            self.x = self.sx
            self.y = self.sy
        else:
            self.y -= 1
        self.x += random.randint(-1, 2)

def main():
    pygame.init()
    screen = pygame.display.set_mode((xmax,ymax))
    black = (0,0,0)
    grey = (145,145,145) …
Run Code Online (Sandbox Code Playgroud)

python refactoring pygame particle-system

5
推荐指数
1
解决办法
6804
查看次数

汇编到C援助

我有一个任务,我需要将程序集转换为C.程序集是x86.我注释了组件并开始填写C中的空白但是我对一些事情有点迷失,有人可以帮忙吗?请解释不要只是给出我正在努力学习的答案.

部件:

x at %ebp+8, n at %ebp+12

1 movl 8(%ebp), %esi  //store x in esi
2 movl 12(%ebp), %ebx //store n in ebx
3 movl $-1, %edi      //result in edi
4 movl $1, %edx       //i of loop in edx
5 .L2:
6 movl %edx, %eax     //move edx to eax
7 andl %esi, %eax     //sum += 1 ...? i think
8 xorl %eax, %edi     //results = results ^ (i & x)
9 movl %ebx, %ecx     //store n in ecx
10 …
Run Code Online (Sandbox Code Playgroud)

c x86 assembly

4
推荐指数
1
解决办法
2483
查看次数

标签 统计

pygame ×3

python ×2

assembly ×1

c ×1

particle-system ×1

refactoring ×1

scroll ×1

x86 ×1