Game Development Reference
In-Depth Information
20 - Dodger
88. reverseCheat = True
89. if event.key == ord('x'):
90. slowCheat = True
91. if event.key == K_LEFT or event.key == ord
('a'):
92. moveRight = False
93. moveLeft = True
94. if event.key == K_RIGHT or event.key ==
ord('d'):
95. moveLeft = False
96. moveRight = True
97. if event.key == K_UP or event.key == ord
('w'):
98. moveDown = False
99. moveUp = True
100. if event.key == K_DOWN or event.key == ord
('s'):
101. moveUp = False
102. moveDown = True
103.
104. if event.type == KEYUP:
105. if event.key == ord('z'):
106. reverseCheat = False
107. score = 0
108. if event.key == ord('x'):
109. slowCheat = False
110. score = 0
111. if event.key == K_ESCAPE:
112. terminate()
113.
114. if event.key == K_LEFT or event.key == ord
('a'):
115. moveLeft = False
116. if event.key == K_RIGHT or event.key ==
ord('d'):
117. moveRight = False
118. if event.key == K_UP or event.key == ord
('w'):
119. moveUp = False
120. if event.key == K_DOWN or event.key == ord
('s'):
121. moveDown = False
122.
123. if event.type == MOUSEMOTION:
124. # If the mouse moves, move the player
where the cursor is.
125. playerRect.move_ip(event.pos[0] -
playerRect.centerx, event.pos[1] - playerRect.centery)
126.
127. # Add new baddies at the top of the screen, if
needed.
128. if not reverseCheat and not slowCheat:
129. baddieAddCounter += 1
130. if baddieAddCounter == ADDNEWBADDIERATE:
Search WWH ::




Custom Search