def draw(self): if (self.heal > 0): self.collisionObject.draw() for pixel in self.points: pyxel.pset(pixel[0], pixel[1], 11) for i in range(1, len(self.points)): point = self.points[i - 1] nextPoint = self.points[i] pyxel.line(point[0], point[1], nextPoint[0], nextPoint[1], self.col) pyxel.line(self.points[0][0], self.points[0][1], self.points[3][0], self.points[3][1], self.col) for shoot in self.shoots: shoot.draw() # pyxel.trib(self.points[0][0],self.points[0][1],self.points[1][0],self.points[1][1],self.points[3][0],self.points[3][1],self.col) if (self.otherPlayer): self.angleController.draw() if (pyxel.btn(pyxel.KEY_TAB)): pyxel.text(self.pos[0] - (len(self.name) * 2), self.pos[1] + 10, self.name, 7) pyxel.rectb(self.pos[0] - 12, self.pos[1] + 16, 24, 8, 7) pyxel.rect(self.pos[0] - 10, self.pos[1] + 18, self.heal / 5, 4, 7)
def draw(self): pyxel.cls(0) # Useful for aligning text # pyxel.line(pyxel.width//4, 0, pyxel.width//4, pyxel.height, 7) # pyxel.line(pyxel.width//2, 0, pyxel.width//2, pyxel.height, 7) # pyxel.line(pyxel.width//4*3, 0, pyxel.width//4*3, pyxel.height, 7) if (self.game_state == 'title'): pyxel.text(93, pyxel.height//2 - 8, 'PASTEL STALACTITES', self.rotating_font_color) pyxel.text(118, pyxel.height//2, self.version, self.rotating_font_color) pyxel.text(100, pyxel.height//2 + 8, 'by Matt Niznik', 11) pyxel.text(85, pyxel.height//2 + 24, '(press SPACE to start)', 7) elif (self.game_state == 'gameover'): pyxel.text(self.game_over_message['x'], pyxel.height//2 - 8, self.game_over_message['msg'], self.rotating_font_color) pyxel.text(80, pyxel.height//2 + 8, 'Score: ' + str(int(self.score)), 7) pyxel.text(80, pyxel.height//2 + 16, 'Distance: ' + str(self.distance), 7) pyxel.text(80, pyxel.height//2 + 24, 'Score/100 px: ' + str(self.ppd), 7) pyxel.text(80, pyxel.height//2 + 40, '(press SPACE to continue)', 7) else: pyxel.rect(self.hero_x, pyxel.height-self.hero_height, self.hero_width, self.hero_height, self.hero_color) pyxel.rectb(self.hero_x, pyxel.height-self.hero_height, self.hero_width, self.hero_height, 7) pyxel.text(40, pyxel.height - 30, 'Score: ' + str(int(self.score)), 7) pyxel.text(40, pyxel.height - 20, 'Distance: ' + str(self.distance), 7) pyxel.text(40, pyxel.height - 10, 'Score/100 px: ' + str(self.ppd), 7) for i in range(0, len(self.stals)): stal = self.stals[i] pyxel.rect(stal['x'], 0, self.stal_width, stal['height'], stal['color']) pyxel.rectb(stal['x'], 0, self.stal_width, stal['height'], 7)
def draw(self): pyxel.cls(1) pyxel.text(6, 6, 'sound(snd).set(note,tone,volume,effect,speed)', 7) pyxel.rect(12, 16, 188, 52, 2) pyxel.text(16, 20, 'note :[CDEFGAB] + [ #-] + [0-4] or [R]', 9) pyxel.text(16, 28, 'tone :[T]riangle [S]quare [P]ulse [N]oise', 9) pyxel.text(16, 36, 'volume:[0-7]', 9) pyxel.text(16, 44, 'effect:[N]one [S]lide [V]ibrato [F]adeOut', 9) pyxel.text(6, 62, 'play(ch,snd,loop=False)', 7) pyxel.text(6, 76, 'stop(ch)', 7) pyxel.rectb(6, 97, 193, 143, 14) pyxel.rect(6, 91, 34, 97, 14) pyxel.text(7, 92, 'CONTROL', 1) pyxel.text(12, 102, '1: Play all channels', 14) pyxel.text(12, 110, '2: Play channel #0 (Melody)', 14) pyxel.text(12, 118, '3: Play channel #1 (Bass)', 14) pyxel.text(12, 126, '4: Play channel #2 (Drums)', 14) pyxel.text(12, 134, '5: Stop playing', 14) for i, v in enumerate(self.is_playing): pyxel.pal(1, v and 15 or 13) pyxel.blt(140 + i * 16, 116 + math.sin(pyxel.frame_count * 0.1 + i * 2.1) * 5, 0, 0, 0, 8, 8, 0) pyxel.pal()
def foundBell(self): if (self.count < 200): pyxel.rect(40, 40, 120, 65, 7) pyxel.rectb(40, 40, 120, 65, 0) pyxel.text(44, 45, "You've obtained the", 0) pyxel.text(50, 55, "Bell of Jingles!", 0) self.count += 1
def draw_field(self): for i, cell in enumerate(self.board): x, y = i % 3, i // 3 if cell == 1: pyxel.rect( x * BLOCK_SIZE , y * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE, 1 ) pyxel.line( (x + 0) * BLOCK_SIZE, (y + 0) * BLOCK_SIZE, (x + 1) * BLOCK_SIZE - 1, (y + 1) * BLOCK_SIZE - 1, 12 ) pyxel.line( (x + 0) * BLOCK_SIZE, (y + 1) * BLOCK_SIZE - 1, (x + 1) * BLOCK_SIZE - 1, (y + 0) * BLOCK_SIZE, 12 ) elif cell == 2: pyxel.rect( x * BLOCK_SIZE , y * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE, 2 ) pyxel.rectb( x * BLOCK_SIZE , y * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE, 14 )
def caughtFish(self): if (self.count < 200): pyxel.rect(40, 40, 120, 65, 7) pyxel.rectb(40, 40, 120, 65, 0) pyxel.text(44, 45, "You've obtained the", 0) pyxel.text(44, 55, "catch of the day!", 0) self.count += 1
def feedCat(self): if (self.count < 200): pyxel.rect(40, 40, 123, 65, 7) pyxel.rectb(40, 40, 123, 65, 0) pyxel.text(44, 45, "You toss fish in!", 0) pyxel.text(44, 55, "You hear purring!", 0) self.count += 1
def zeige_auswahl(self, zeile, spalte, farbe): x1 = spalte * self.spalten_breite x2 = (spalte + 1) * self.spalten_breite - 1 y1 = zeile * self.zeilen_hoehe y2 = (zeile + 1) * self.zeilen_hoehe - 1 pyxel.rectb(x1, y1, x2, y2, farbe)
def renderEntitiesColliders(self, camera, world): entities = list(world.querryEntities(camera.inflated(Vector2f(48, 64)))) if entities != None: entities.sort(key=Renderer.entityKey) for entity in entities: entityPosFromCam = entity.position - camera.position colliders = entity.getComponent('ColliderList') if colliders: for c in colliders: if c.type == Collider.BOUNDINGBOX: pyxel.rectb( entityPosFromCam.x - c.position.x, entityPosFromCam.y - c.position.y, entityPosFromCam.x - c.position.x + c.size.x, entityPosFromCam.y - c.position.y + c.size.y, Color.Black) elif c.type == Collider.TRIGGERBOX: pyxel.rectb( entityPosFromCam.x - c.position.x, entityPosFromCam.y - c.position.y, entityPosFromCam.x - c.position.x + c.size.x, entityPosFromCam.y - c.position.y + c.size.y, Color.Yellow) self.primitiveDrawn += len(colliders)
def draw_minimap(self): # Draw the map for y in range(len(level)): for x in range(len(level[0])): tile = level[y][x] pyxel.rect(x * scale, y * scale, scale, scale, tile) # Find intersections for the middle ray. # x1, y1, x2, y2, dx1, dy1, dx2, dy2 = ray(X, Y, phi) wx, wy, ix, iy = trace(X, Y, *ray(X, Y, phi)) pyxel.rectb(wx * scale, wy * scale, scale, scale, 8) # Draw facing ray pyxel.line(X * scale, Y * scale, ix * scale, iy * scale, 8) # Draw edges of FOV if draw_FOV: wx, wy, ix, iy = trace(X, Y, *ray(X, Y, left_extreme(phi))) pyxel.line(X * scale, Y * scale, ix * scale, iy * scale, 5) wx, wy, ix, iy = trace(X, Y, *ray(X, Y, left_extreme(phi) + FOV_rad)) pyxel.line(X * scale, Y * scale, ix * scale, iy * scale, 11) # Draw player pyxel.rect(round((X - R) * scale), round((Y - R) * scale), 2 * R * scale, 2 * R * scale, 8)
def draw_before_children(self): pyxel.rectb(*self.graph_tl, *self.graph_size, 7) pyxel.rectb(*self.graph_tl.br_of(Point(0, self.graph_size.y)), *self.graph_size.scale2D(Size(1, 2)), 7) self.draw_func_with_col(self.f, 8) self.draw_func_with_col(self.g, 9) self.draw_func_with_col(self.h, 10)
def draw(self, hightlight): if hightlight: pyxel.rect(self.x, self.y, self.x + self.size, self.y + self.size, 8) else: pyxel.rectb(self.x, self.y, self.x + self.size, self.y + self.size, 9)
def _obstacle_anim(self, x, y): x, y = x - 8, y - 8 state_duration = 3 cur = (pyxel.frame_count // state_duration) % 6 col = 7 if cur == 3 else 11 pyxel.rectb(x, y, x + 16, y + 16, col) if cur == 3: pyxel.rectb(x + 1, y + 1, x + 15, y + 15, col)
def draw_small_map(self): # スモールマップの描画みたことあるところだけ描画 smap_margin = 15 # [pix] for i in range(self.map.w): for j in range(self.map.h): x = i + smap_margin y = j + smap_margin if self.map.data[j, i] == 0: if self.is_seen[j, i] == True: pyxel.rect(x, y, 1, 1, 5) else: pass # pyxel.rect(x, y, 1, 1, 12) # スモールマップの自キャラと視野範囲の描画 _, self.margins = self.map.get_local_data(self.ego.y, self.ego.x) lsmx, rsmx, usmy, dsmy = self.margins cx = int(self.ego.x) cy = int(self.ego.y) pyxel.rect(cx + smap_margin, cy + smap_margin, 1, 1, 11) pyxel.rectb(cx - lsmx + smap_margin, cy - usmy + 15, 16, 16, 8) # 敵の位置 for enemy in self.enemies: ex = enemy.x ey = enemy.y pyxel.rect(ex + smap_margin, ey + smap_margin, 1, 1, 8)
def draw(self, state): lines = wrap(self.text, 16) pyxel.rect(20, 38, 88, 10 + 8*len(lines), 0) pyxel.rectb(20, 38, 88, 10 + 8*len(lines), 6) pyxel.blt(25, 44, 0, *ITEMS[self.icon]) for i, l in enumerate(lines): pyxel.text(38, 43 + i * 8, l, 6)
def drawGizmos(self, camera): for b in self.gizmos: entityPosFromCam = b[0].position - camera.position pyxel.rectb(entityPosFromCam.x, entityPosFromCam.y, entityPosFromCam.x + b[0].size.x, entityPosFromCam.y + b[0].size.y, b[1]) self.gizmos.clear()
def draw(self): pyxel.cls(1) pyxel.text(6, 6, "sound(snd).set(note,tone,volume,effect,speed)", 7) pyxel.rect(12, 14, 177, 35, 2) pyxel.text(16, 17, "note :[CDEFGAB] + [ #-] + [0-4] or [R]", 9) pyxel.text(16, 25, "tone :[T]riangle [S]quare [P]ulse [N]oise", 9) pyxel.text(16, 33, "volume:[0-7]", 9) pyxel.text(16, 41, "effect:[N]one [S]lide [V]ibrato [F]adeOut", 9) pyxel.text(6, 53, "music(msc).set(ch0,ch1,ch2,ch3)", 7) pyxel.text(6, 62, "play(ch,snd,loop=False)", 7) pyxel.text(6, 71, "playm(msc,loop=False)", 7) pyxel.text(6, 80, "stop([ch])", 7) pyxel.rectb(6, 97, 188, 47, 14) pyxel.rect(6, 91, 29, 7, 14) pyxel.text(7, 92, "CONTROL", 1) pyxel.text(12, 102, "1: Play all channels", 14) pyxel.text(12, 110, "2: Play channel #0 (Melody)", 14) pyxel.text(12, 118, "3: Play channel #1 (Bass)", 14) pyxel.text(12, 126, "4: Play channel #2 (Drums)", 14) pyxel.text(12, 134, "5: Stop playing", 14) pyxel.text(137, 107, "play_pos(ch)", 15) for i in range(3): x = 140 + i * 16 y = 123 + math.sin(pyxel.frame_count * 0.1 + i * 2.1) * 5 col = 15 if pyxel.play_pos(i) else 13 pyxel.pal(1, col) pyxel.blt(x, y, 0, 0, 0, 8, 8, 0) pyxel.pal()
def renderColliderOverlay(self, camera, world): regionIndexList = world.querryRegions(camera) for regionIndex in regionIndexList: region = world.regions[regionIndex] if region.tilemap: tilesIndexList = region.querryTiles(camera) for tileIndex in tilesIndexList: tile = region.tilemap.tiles[tileIndex] tilePosFromCam = region.position + 16 * Vector2f( tile.position.x, tile.position.y) - camera.position for layer in sorted(tile.materials): material = tile.materials[layer] colliderList = world.terrainBank.getColliders( material.index) if colliderList: for c in colliderList: p1 = tilePosFromCam + c.position p2 = tilePosFromCam + c.position + c.size if material.flip.x == -1: p1.x = tilePosFromCam.x + 15 - c.position.x p2.x = tilePosFromCam.x + 15 - c.position.x - c.size.x if material.flip.y == -1: p1.y = tilePosFromCam.y + 16 - c.position.y p2.y = tilePosFromCam.y + 16 - c.position.y - c.size.y pyxel.rectb(p1.x, p1.y, p2.x, p2.y, 0) self.primitiveDrawn += len(colliderList)
def hungryCat(self): if (self.count < 200): pyxel.rect(40, 40, 120, 65, 7) pyxel.rectb(40, 40, 120, 65, 0) pyxel.text(44, 45, "You hear pained", 0) pyxel.text(44, 55, "yollowing inside!", 0) self.count += 1
def __on_draw(self): pyxel.blt(self.x, self.y, 3, 0, 192, 64, 63) x = self.x + self.parent.edit_x // 4 y = self.y + self.parent.edit_y // 4 height = 4 if self.parent.edit_y < 240 else 3 pyxel.rectb(x - 1, y - 1, x + 4, y + height, 7)
def jingleCat(self): if (self.count < 200): pyxel.rect(40, 40, 122, 65, 7) pyxel.rectb(40, 40, 122, 65, 0) pyxel.text(44, 45, "You jingle the bell!", 0) pyxel.text(44, 55, "Something is coming!", 0) self.count += 1
def draw(self, x, y): # Background pyxel.rect(x + 2, y + 2, x + 52, y + 19, 1) pyxel.rectb(x + 2, y + 2, x + 52, y + 19, 5) # Rack number pyxel.rect(x + 4, y + 4, x + 12, y + 10, 10) offset_x = 0 if self._rack.number != "10": offset_x = 2 pyxel.text(x + 5 + offset_x, y + 5, self._rack.number, 0) # Server self._server.draw(x + 16, y + 4) # Server value pyxel.text(x + 17, y + 12, str(self._server.value), TXT_COLOR) # CPU self._cpuitem.draw(x + 38, y + 4) if self._server._cpu: pyxel.text(x + 48, y + 4, str(self._server._cpu), TXT_COLOR) # RAM self._ramitem.draw(x + 38, y + 12) if self._server._ram: pyxel.text(x + 48, y + 12, str(self._server._ram), TXT_COLOR)
def draw(self): pyxel.cls(0) for i, cell in enumerate(self.maze): x, y = i % BOARD_WIDTH, i // BOARD_WIDTH scr_x, scr_y = x * BLOCK_SIZE, y * BLOCK_SIZE pyxel.rect(scr_x, scr_y, BLOCK_SIZE, BLOCK_SIZE, WALL_COLOR) if cell & VISTED: pyxel.rect(scr_x + WALL_SIZE, scr_y + WALL_SIZE, CELL_SIZE, CELL_SIZE, CELL_COLOR) if cell & UP: pyxel.rect(scr_x + WALL_SIZE, scr_y, CELL_SIZE, WALL_SIZE, CELL_COLOR) if cell & LEFT: pyxel.rect(scr_x, scr_y + WALL_SIZE, WALL_SIZE, CELL_SIZE, CELL_COLOR) if cell & DOWN: pyxel.rect(scr_x + WALL_SIZE, scr_y + WALL_SIZE + CELL_SIZE, CELL_SIZE, WALL_SIZE, CELL_COLOR) if cell & RIGHT: pyxel.rect(scr_x + WALL_SIZE + CELL_SIZE, scr_y + WALL_SIZE, WALL_SIZE, CELL_SIZE, CELL_COLOR) x, y = self.pos pyxel.rectb(x * BLOCK_SIZE + WALL_SIZE, y * BLOCK_SIZE + WALL_SIZE, CELL_SIZE, CELL_SIZE, 2 if self.running else 1)
def draw(self): px.blt(self.position.x, self.position.y, 0, *self.current_sprite, 0) if self.debug_mode: for i in self.cell_to_check: px.rectb(i.x * 8, i.y * 8, 8, 8, 6) px.rectb(self.position.x, self.position.y, self.dimension.x, self.dimension.y, 6)
def draw(self): pyxel.cls(0) # pyxel.rect(230, 135, 2, 2, 13) for i in range(32): if (self.score>>i)&1: x, y = 230-4*i, 135 pyxel.rect(x, y, 2, 2, 3) for rx, ry, col in self.rect_effects: pyxel.rect(rx, ry, 2, 2, col) kx, ky = self.keys_pos for i, key in enumerate(self.keys): flag = self.key_flags[i] char, (x, y) = key pyxel.rectb(kx+x, ky+y, 12, 12, [13, 5][flag]) pyxel.text(kx+2+x, ky+2+y, str.upper(char), [0, 6][flag]) # pyxel.blit(20, 10) pyxel.text(20, 20, f"score: {self.score}", 7) pyxel.text(80, 30, (f"{self.before_question}"), 1) pyxel.text(80, 40, ":", 13) pyxel.text(80+4, 40, (f"{self.question}"), 12) pyxel.text(80, 50, ":", 13) pyxel.text(80+4, 50, self.answer, 13) self.score_before = self.score
def draw_floor(self): ''' Draw the floor and the ladders :return: ''' # guardamos la altura de las plataformas y las vamos restando esc_y = constants.suelo_y for i in range(0, constants.n_plataformas): esc_y -= constants.distance_bt_floors # dibujamos el suelo pyxel.blt(constants.suelo_x, esc_y, 0, 0, 16, constants.ventana_x, constants.suelo_h) if len(self._h_suelo) != 6: self._h_suelo.append(esc_y - constants.suelo_h - 5) if i != 0: # dibujamos las escaleras pyxel.rectb(constants.escalera_x[i], esc_y + (constants.suelo_h / 2), constants.escalera_w, constants.escalera_h - (constants.suelo_h / 2), i + 1) # guardamos las posiciones de la escalera concretamente los lados del rectangulo # x1, y1, x2(x1+w), y2(y1+h) if len(self._posiciones_escaleras) != 5: self._posiciones_escaleras.append( (constants.escalera_x[i], esc_y + (constants.suelo_h / 2) + constants.escalera_h, constants.escalera_x[i] + constants.escalera_w, esc_y + (constants.suelo_h / 2))) # escalera para subir hasta mario pyxel.rectb(45, 25, constants.escalera_w, constants.escalera_h - (constants.suelo_h / 2), 15)
def draw(self): col = self.blink_col if self.blink_frame > 0 else self.rect_col pyxel.rectb(self.x, self.y, self.size, self.size, col) s = str(self.num) dw = -(-(self.size - (len(s) * 4 - 1)) // 2) dh = -(-(self.size - 5) // 2) pyxel.text(self.x + dw, self.y + dh, s, self.num_col)
def draw(self): pyxel.cls(1) x = self.x y = self.y u = self.u v = self.v w, h = 32, 32 # background pyxel.blt(0, 0, 0, 0, 0, 32 * 4, 32 * 4, 11) # info background pyxel.rectb(u, v, w, h, 10) pyxel.text(u - 16, v - 8, '(U,V)', 10) pyxel.text(u + w // 2 - 2, v + h + 2, 'W', 10) pyxel.text(u + w + 2, v + h // 2 - 2, 'H', 10) # sprite pyxel.blt(x, y, 0, u, v, w, h, 11) # info sprite pyxel.rectb(x, y, w, h, 8) pyxel.text(x - 16, y - 8, '(X,Y)', 8) pyxel.text(x + w // 2 - 2, y + h + 2, 'W', 8) pyxel.text(x + w + 2, y + h // 2 - 2, 'H', 8) # function pyxel.text(128, 120, 'pyxel.blt(X,Y,BANK,U,V,W,H)', 7)
def __on_draw(self): self.draw_panel(self.x, self.y, self.width, self.height) pyxel.blt( self.x + 1, self.y + 1, 3, TILEMAP_IMAGE_X, TILEMAP_IMAGE_Y, TILEMAP_IMAGE_WIDTH, TILEMAP_IMAGE_HEIGHT, ) pyxel.clip(self.x + 1, self.y + 1, self.x + self.width - 2, self.y + self.height - 2) x1 = self.x + self.parent.drawing_x // 4 + 1 y1 = self.y + self.parent.drawing_y // 4 + 1 x2 = x1 + 3 y2 = y1 + 3 pyxel.rectb(x1, y1, x2, y2, 7) pyxel.rectb(x1 - 1, y1 - 1, x2 + 1, y2 + 1, 0) pyxel.clip()
def DebugDrawPosHitRect(self): if imp._DEBUG_ == True: pyxel.pset(self.PosX, self.PosY, pyxel.frame_count % 16) pyxel.rectb(self.PosX - (self.HitRectX / 2), self.PosY - (self.HitRectY / 2), self.HitRectX, self.HitRectY, pyxel.frame_count % 16) return