NES-like sprite interface for pygame
Class representing an NES palette
The 'palette' argument must contain 3 values among the ones contained in the Color Reference
Example:
Super Mario's palette from Super Mario Bros can be:
('0x16', '0x18', '0x28')
The hex value is case sensitive, the 'x' must be lowercase, the digits must be uppercase
Instances of 'Palette' are iterables, elements can be edited but not added or deleted
Class representing an NES sprite
The 'data' argument must be an hex value, the exact value can be obtained by using the pixeltohex.py script
The 'size' argument must be a tuple containing two elements: (number of horizontal tiles, number of vertical tiles)
The 'palette' argument must be a pynes.Palette instance
Size of a single "pixel" of the sprite, measured in pixels
Palette currently used by the sprite
Number of orizontal and vertical tiles
Colors used in each pixel
Image composed using the hex value recived
Updates the sprite
If the sprite is part of a pygame.sprite.Group you can also use pygame.sprite.Group.update()
Saves the generated sprite in name.png
Changes the current hex value for the sprite
Class representing an NES tile
The 'data' argument must be an hex value, the exact value can be obtained by using the pixeltohex.py script
The 'palette' argument must be a pynes.Palette instance
Size of a single "pixel" of the tile, measured in pixels
Palette currently used by the tile
Colors used in each pixel
Updates the tile
Saves the generated tile in name.png
Changes the current hex value for the tile
Updates every pynes.NESSprite instance
Creates a static image from an hex value, useful for creating animated sprites without having to re-parse data every frame
The 'image_data' argument must be an hex value, the exact value can be obtained by using the pixeltohex.py script
The 'palette' argument must be a pynes.Palette instance
The 'size' argument must be a tuple containing two elements: (number of horizontal tiles, number of vertical tiles)
The 'pixel_size' argument represents how many pixels is a single square in the sprite
A script that generates a readable hex value for the NESSprite
The input must be written in a file named 'convert.dat', every character must correspond to a pixel in the image, lines can be wrapped
Accepted characters: 0, 1, 2, 3
Every character must be the index of the color used in that pixel in the palette, 0 is transparent
The result will be written in 'result.dat'
Example:
0000001111100000
0000113222311000
0001322222223100
0013222222222100
0012222222222310
0122222221212310
1322222221212221
1222222221212221
1222223322223321
1322322222222321
0132122222122131
0011322222223110
0001133222231100
0013311111113310
0133333111133331
0011111000111110
will return
0x0300E0000E0338E0180F0CF8301F04F8201F06FC403F56ACC07F51AE807F51AE837F0DFEC87F05FE683727DA380F0EF81E071CF03F18FE0C7F3EFF1E3E003E0
And when converted it will become Kirby's sprite
Script that can be used to test if a sprite displays correctly
The input must be in a file called 'test.dat', and it must be formatted in this way:
hex value (without 0x)
number of horizontal tiles
number of vertical tiles
element [1] in the palette
element [2] in the palette
element [3] in the palette
The result will be saved in 'test.png'
0x00
0x01
0x02
0x03
0x04
0x05
0x06
0x07
0x08
0x09
0x0A
0x0B
0x0C
0x0D
0x0E
0x0F
0x10
0x11
0x12
0x13
0x14
0x15
0x16
0x17
0x18
0x19
0x1A
0x1B
0x1C
0x1D
0x1E
0x1F
0x20
0x21
0x22
0x23
0x24
0x25
0x26
0x27
0x28
0x29
0x2A
0x2B
0x2C
0x2D
0x2E
0x2F
0x30
0x31
0x32
0x33
0x34
0x35
0x36
0x37
0x38
0x39
0x3A
0x3B
0x3C
0x3D
0x3E
0x3F