ausetr.blogg.se

Sprite monkey png
Sprite monkey png







sprite monkey png
  1. #SPRITE MONKEY PNG FULL#
  2. #SPRITE MONKEY PNG CODE#

You can also pass a value of -1 as the colorkey. This would usually just be a color RGB value, like (255, 255, 255) for If the user supplied an argumentįor the colorkey argument we use that value as the colorkey for the image. To scaleīy a scalar, we can get the size and scale the x and y by the scalar. This function takes a Surface and the size it should be scaled to. We then scale the image, using the () resize to new resolution function. Image to the screen will happen as quickly as possible. Its color format and depth to match the display. This makes a new copy of a Surface and converts Next we load the image using the () load new image from a file (or file-like object) function.Īfter the image is loaded, we make an importantĬall to the convert() function. The os.path.join function, a pathname will be created that works for whatever In this example all the resources are in a "data" subdirectory.

#SPRITE MONKEY PNG FULL#

The first thing this function does is create a full pathname to the file.

sprite monkey png

A colorkey is used in graphics to represent a color of the Takes an argument it can use to set a colorkey for the image, and an argument This function takes the name of an image to load. convert () if colorkey is not None : if colorkey = - 1 : colorkey = image. get_size () size = ( size * scale, size * scale ) image = pg. Look at each function individually in this section.ĭef load_image ( name, colorkey = None, scale = 1 ): fullname = os. Here we have two functions we can use to load images and sounds. It then prepares the variable data_dir to tell the Main_dir uses the os.path module and the _file_ variable providedīy Python to locate the game's python file, and extract the folder from

#SPRITE MONKEY PNG CODE#

Lastly, we prepare two paths for the rest of the code to use. (Although they will only be unavailable in very uncommon situations). Mixer modules in pygame are not available. Some pygame modules are optional, and if they aren't found, Pygame as pg, so that all of the functionality of pygame is able to In the next line, we import the pygame package. Us to do things like create platform independent file paths. join ( main_dir, "data" )įirst, we import the standard "os" python module. mixer : print ( "Warning, sound disabled" ) main_dir = os. font : print ( "Warning, fonts disabled" ) if not pg. # Import Modules import os import pygame as pg if not pg.









Sprite monkey png