-
Notifications
You must be signed in to change notification settings - Fork 7
/
sprites_nsmb2.py
133 lines (99 loc) · 3.72 KB
/
sprites_nsmb2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/python
# -*- coding: latin-1 -*-
# Reggie Next - New Super Mario Bros. Wii / New Super Mario Bros 2 Level Editor
# Milestone 2 Alpha 4
# Copyright (C) 2009-2014 Treeki, Tempus, angelsl, JasonP27, Kamek64,
# MalStar1000, RoadrunnerWMC
# This file is part of Reggie Next.
# Reggie Next is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# Reggie Next is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with Reggie Next. If not, see <http://www.gnu.org/licenses/>.
# sprites_nsmb2.py
# Contains code to render sprite images from New Super Mario Bros. 2
################################################################
################################################################
# Imports
from PyQt5 import QtCore, QtGui
Qt = QtCore.Qt
import spritelib as SLib
ImageCache = SLib.ImageCache
import sprites_common
################################################################
################################################################
def LoadBasics():
"""
Loads basic images used in NSMB2
"""
# Load some coins, because coins are in almost every Mario level ever
ImageCache['Coin'] = SLib.GetImg('coin.png')
ImageCache['StarCoin'] = SLib.GetImg('starcoin.png')
# Load blocks
BlockImage = SLib.GetImg('blocks.png')
Blocks = []
count = BlockImage.width() // 24
for i in range(count):
Blocks.append(BlockImage.copy(i * 24, 0, 24, 24))
ImageCache['Blocks'] = Blocks
# Load the overrides
Overrides = QtGui.QPixmap('reggiedata/overrides.png')
Blocks = []
x = Overrides.width() // 24
y = Overrides.height() // 24
for i in range(y):
for j in range(x):
Blocks.append(Overrides.copy(j * 24, i * 24, 24, 24))
ImageCache['Overrides'] = Blocks
# Load vines, because these are used by entrances
SLib.loadIfNotInImageCache('VineTop', 'vine_top.png')
SLib.loadIfNotInImageCache('VineMid', 'vine_mid.png')
SLib.loadIfNotInImageCache('VineBtm', 'vine_btm.png')
class SpriteImage_BobOmb(SLib.SpriteImage_Static): # 29
def __init__(self, parent):
super().__init__(
parent,
1.25,
ImageCache['BobOmb'],
(-2, -9),
)
@staticmethod
def loadImages():
SLib.loadIfNotInImageCache('BobOmb', 'bob-omb.png')
class SpriteImage_Coin(SLib.SpriteImage_Static): # 55
def __init__(self, parent):
super().__init__(
parent,
1.25,
ImageCache['Coin'],
)
class SpriteImage_FireballPipeJunction(SLib.SpriteImage_Static): # 81
def __init__(self, parent):
super().__init__(
parent,
1.25,
ImageCache['FireballPipeJunction'],
)
@staticmethod
def loadImages():
SLib.loadIfNotInImageCache('FireballPipeJunction', 'block_fireball_pipe.png')
class SpriteImage_StarCoin(SLib.SpriteImage_Static): # 219
def __init__(self, parent):
super().__init__(
parent,
1.25,
ImageCache['StarCoin'],
)
################################################################
################################################################
ImageClasses = {
29: SpriteImage_BobOmb,
55: SpriteImage_Coin,
81: SpriteImage_FireballPipeJunction,
219: SpriteImage_StarCoin,
}