此为历史版本和 IPFS 入口查阅区,回到作品页
wenwen
IPFS 指纹 这是什么

作品指纹

025第12章 A SHIP THAT FIRES BULLETS_續2_get_rect()方法

wenwen
·
·
書上的程式都還沒動手寫,儘管看得懂,還是有一種虛虛的感覺。

💛20230125晨讀感言:

💔在python裡,儲存圖像的檔案格式是 bmp,而一般我們若使用 jpg 或 png 的檔案格式時,在python中使用時就必須經過轉換為 bmp。

💔在 python 撰寫 2D 遊戲時,所看到的 螢幕畫面及其elements,不管外表形狀如何,在程式中,都是使用 rectangles(矩形)來表達,這樣的好處就是可以使用 x , y 座標 來精確 指定其 所在位置。

💔呈上,在Pygame中,原點(0,0)位於屏幕的左上角,坐標隨你向下和向右增加。這和我們以前在 數學 中 學到的 「原點坐標所在位置 及 向上增加」 完全不一樣。

💛晨讀摘要:

💚231 Colors in Pygame are specified as RGB colors: a mix of red, green, and blue. Each color value can range from 0 to 255. The color value (255, 0, 0) is red, (0, 255, 0) is green, and (0, 0, 255) is blue. You can mix different RGB values to create up to 16 million colors. The color value (230, 230, 230) mixes equal amounts of red, blue, and green, which produces a light gray background color.

💚232 When you’re choosing artwork for your games, be sure to pay attention to licensing. The safest and cheapest way to start is to use freely licensed graphics that you can use and modify, from website like https://pixabay.com/. You can use almost any type of image file in your game, but it’s easiest when you use a bitmap (.bmp) file because ==Pygame loads bitmaps by default==.

💚234 ==Pygame is efficient because it lets you treat all game elements like rectangles (rects), even if they’re not exactly shaped like rectangles==. Treating an element as a rectangle is efficient because rectangles are simple geometric shapes. When Pygame needs to figure out whether two game elements have collided, for example, it can do this more quickly if it treats each object as a rectangle. This approach usually works well enough that no one playing the game will notice that we’re not working with the exact shape of each game element. ==We’ll treat the ship and the screen as rectangles in this class==.

💚235 In Pygame, the origin (0, 0) is at the top-left corner of the screen, and coordinates increase as you go down and to the right. On a 1200 by 800 screen, the origin is at the top-left corner, and the bottom-right corner has the coordinates (1200, 800). These coordinates refer to the game window, not the physical screen.

from:《python crash course》

CC BY-NC-ND 2.0 授权