0

帮助!我是编程新手!我正在尝试制作一个垄断游戏。到目前为止,我的程序创建了玩家和卡片对象,这些对象存储了一些值。

我正在尝试使用 pygame 来实现某种动画并创建一个在 pygame 屏幕上弹出的菜单栏,但我不知道如何开始。到目前为止,我只有一个 pygame 背景屏幕,我想知道如何根据玩家对象的位置值在 pygame 屏幕给定位置放置一个小矩形。我需要知道如何才能拥有我为游戏逻辑编写的所有代码,并让它与这个 pygame 东西一起运行。

我真的需要知道如何开始。如果有人愿意花一些时间和我在一起,让我朝着正确的方向前进,我将不胜感激,谢谢!

4

1 回答 1

1

阅读一些pygame 教程肯定会有所帮助。

您的程序流程最终将如下所示:

# This is intentionally simplified pseudocode, but at the bottom-most level most
#    simple games have a similar structure to this.

#Construct your game objects
players = [Player(args) for n in range(num_players)]
cards = loadCards()   #or however you load your cards (files,database,etc)
board = Board()

#initialize your display context
pygame_screen.init()  #or whatever is the correct syntax for Pygame

# Main game loop
while 1:
    check_inputs()    #get key/mouse input inputs for this frame
    handle_inputs()    #handle each input that has occurred during this frame
    update_gamestate()    #update the state on the game (who's turn, etc)
    update_display()    #update pygame window graphics (draw stuff, flip display)

cleanup()

至于如何绘制矩形之类的细节,你应该在这里阅读各种绘制函数

于 2013-09-06T23:22:03.743 回答