diff --git a/.inscode b/.inscode index ecc8bdde946f464a2c4d431d8f8196413737d922..75faea00a164f634a325e99979a67b86786ac578 100644 --- a/.inscode +++ b/.inscode @@ -1,6 +1,10 @@ run = "npm i && npm run dev" +language = "python" [env] -PATH = "/root/${PROJECT_DIR}/.config/npm/node_global/bin:/root/${PROJECT_DIR}/node_modules/.bin:${PATH}" +PATH = "/root/${PROJECT_DIR}/.config/npm/python_global/bin:/root/${PROJECT_DIR}/python_modules/.bin:${PATH}" XDG_CONFIG_HOME = "/root/.config" -npm_config_prefix = "/root/${PROJECT_DIR}/.config/npm/node_global" \ No newline at end of file +npm_config_prefix = "/root/${PROJECT_DIR}/.config/npm/python_global" + +[debugger] +program = "main.py" diff --git a/QuickDraw TCG.pyw b/QuickDraw TCG.pyw new file mode 100644 index 0000000000000000000000000000000000000000..56964a037d7bd6a0c08b5cc7873ed6f311bb6e3f --- /dev/null +++ b/QuickDraw TCG.pyw @@ -0,0 +1,1026 @@ +#!/usr/bin/python3.4 +# Setup Python ----------------------------------------------- # +import pygame, sys, random, time, os, entities, text +from datetime import datetime +# Setup pygame/window ---------------------------------------- # +x = 100 +y = 100 +os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (x,y) +mainClock = pygame.time.Clock() +from pygame.locals import * +pygame.mixer.pre_init(44100, -16, 2, 512) +pygame.init() +pygame.display.set_caption('QuickDraw TCG') +WINDOWWIDTH = 600 +WINDOWHEIGHT = 450 +screen = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT),0,32) +display = pygame.Surface((200,150)) +# Images ----------------------------------------------------- # +def load_img(path): + img = pygame.image.load('data/images/' + path + '.png').convert() + img.set_colorkey((255,255,255)) + return img + +ground_img = load_img('ground') + +player_standing = load_img('player/standing') +player_jumping = load_img('player/jumping') +player_dead = load_img('player/dead') + +plant_images = entities.load_sequence('data/images/plant_',5) +cloud_images = entities.load_sequence('data/images/cloud_',4) +jump_anim = entities.load_sequence('data/images/vfx/jump/',7) +turn_anim = entities.load_sequence('data/images/vfx/turn/',6) + +sun = load_img('sun') +sun2 = load_img('sun2') + +meteor_1 = load_img('meteor_1') +meteor_1_trail = load_img('meteor_1_trail') +meteor_2 = load_img('meteor_2') +meteor_2_trail = load_img('meteor_2_trail') +bullet_img = load_img('bullet') + +card_item_img = load_img('card') +card_item_img2 = load_img('card2') + +card_back = load_img('card_back') +description = load_img('description') + +select = load_img('select') +cancel = load_img('cancel') + +heart = load_img('heart') + +score_box = load_img('score_box') + +death_img = load_img('death') + +spikes = [load_img('spikes_1'),load_img('spikes_2'),load_img('spikes_3')] +tumbleweed = [load_img('tumbleweed_1'),load_img('tumbleweed_2'),load_img('tumbleweed_3')] + +z_img = load_img('z') + +platform_img = load_img('platform') + +instructions_img = load_img('instructions') +# Audio ------------------------------------------------------ # +def load_snd(name): + return pygame.mixer.Sound('data/sfx/' + name + '.wav') + +card_0_s = load_snd('card_0') +card_1_s = load_snd('card_1') +meteor_s = load_snd('meteor') +bullet_s = load_snd('bullet') +hurt_s = load_snd('hurt') +card_0_s.set_volume(0.4) +card_1_s.set_volume(0.25) + +pygame.mixer.music.load('data/music/main.wav') +# Colors ----------------------------------------------------- # +BACKGROUND = (219,210,202) +# Font ------------------------------------------------------- # +font_dat = {'A':[3],'B':[3],'C':[3],'D':[3],'E':[3],'F':[3],'G':[3],'H':[3],'I':[3],'J':[3],'K':[3],'L':[3],'M':[5],'N':[3],'O':[3],'P':[3],'Q':[3],'R':[3],'S':[3],'T':[3],'U':[3],'V':[3],'W':[5],'X':[3],'Y':[3],'Z':[3], + 'a':[3],'b':[3],'c':[3],'d':[3],'e':[3],'f':[3],'g':[3],'h':[3],'i':[1],'j':[2],'k':[3],'l':[3],'m':[5],'n':[3],'o':[3],'p':[3],'q':[3],'r':[2],'s':[3],'t':[3],'u':[3],'v':[3],'w':[5],'x':[3],'y':[3],'z':[3], + '.':[1],'-':[3],',':[2],':':[1],'+':[3],'\'':[1],'!':[1],'?':[3], + '0':[3],'1':[3],'2':[3],'3':[3],'4':[3],'5':[3],'6':[3],'7':[3],'8':[3],'9':[3], + '(':[2],')':[2],'/':[3],'_':[5],'=':[3],'\\':[3],'[':[2],']':[2],'*':[3],'"':[3],'<':[3],'>':[3],';':[1]} +font = text.generate_font('data/fonts/small_font.png',font_dat,5,8,(185,57,57)) +font_2 = text.generate_font('data/fonts/small_font.png',font_dat,5,8,(51,34,40)) +# Functions -------------------------------------------------- # +def flip(img): + return pygame.transform.flip(img,True,False) + +def generate_plants(plants): + plant_list = [] + x = -14 + while x < 200: + x += random.randint(14,36) + plant_list.append([x,random.randint(0,len(plants)-1)]) + return plant_list + +def generate_clouds(clouds): + cloud_list = [] + for i in range(random.randint(5,9)): + cloud_list.append([random.randint(-30,190),random.randint(2,100),random.randint(0,len(clouds)-1)]) + return cloud_list +# Variables -------------------------------------------------- # +player = entities.entity(100,129,8,14) +player_walking = entities.animation([[0,2],[1,2],[2,2],[3,2]],'data/images/player/walking/walking_',['loop']) +player_key = player_walking.start(player.x,player.y) +player_grav = 0 +right = False +left = False +last_dir = 'r' +jumps = 1 +air_time = 0 +health = 3 +invincibility = 0 + +base_walls = [[-10,0,10,150],[200,0,10,150],[0,143,200,7]] + +plants = generate_plants(plant_images) +clouds = generate_clouds(cloud_images) + +base_spawn_rates = {'meteors':2,'bullet':0,'tumbleweed':0} +spawn_rates = base_spawn_rates.copy() +spawn_rate_multipliers = {'meteors':1,'cards':1,'bullet':1,'tumbleweed':1} + +projectiles = [] +static_images = [] +circle_particles = [] + +base_cards = ['1 point','1 point','1 point','1 point','double jump 5s','double jump 5s', 'double jump 5s', 'double jump 5s', + 'invincible 3s', 'speed 5s', 'double jump 5s', + 'invincible 3s', 'speed 5s', 'speed 5s', 'speed 5s'] +cards = base_cards.copy() +card_types = ['reduce bullets 10s','speed 5s','triple jump 10s','platform','quick draw 5s','reduce meteorites 10s','double jump 5s','invincible 3s','heal','1 point'] +card_chances = {'reduce bullets 10s':1,'speed 5s':2,'triple jump 10s':1,'platform':4,'quick draw 5s':2, 'reduce meteorites 10s':2, 'double jump 5s': 3, 'invincible 3s': 2, 'heal': 3, '1 point': 1} +card_images = {} +deck = cards.copy() +hand = [] +for card in card_types: + card_images[card] = load_img('cards/' + card) +card_visuals = [] +box_pos = 200 +select_pos = -75 +cancel_pos = -75 + +hovered_card = 0 + +paused = False +pause_cooldown = 0 + +card_items = [] + +particles = [] + +sun_timer = 0 + +score = 0 +goal = 3 + +death_pos = -30 +death_target = -30 + +time_since_card = 0 + +level = 1 + +z_pos = 200 +z_pressed = False + +# jump cap, duration +jump_cap = [1,0] + +effects = [] + +fade = 0 + +dead_timer = -1 + +level_name = ['10:00AM - Day 1',0] + +spike_timer = 0 + +platforms = [] + +speed_multiplier = [1,0] + +animations = [] + +moved = False +instructions_pos = 200 +instructions_target = 50 + +sun_pos = [18,40] +# Loop ------------------------------------------------------- # +pygame.mixer.music.play(-1) +pygame.mixer.music.set_volume(0.45) +while True: + # Background --------------------------------------------- # + if level_name[0][:2] == '10': + sun_pos = [18,40] + elif level_name[0][:2] == '11': + sun_pos = [50,20] + else: + sun_pos = [95,10] + if hovered_card < 0: + hovered_card = 0 + mx,my = pygame.mouse.get_pos() + spawn_rate_multipliers = {'meteors':1,'cards':1,'bullet':1,'tumbleweed':1} + mx = int(mx/(WINDOWWIDTH/200)) + my = int(my/(WINDOWHEIGHT/150)) + tiles = base_walls.copy() + for platform in platforms: + tiles.append(platform) + display.fill(BACKGROUND) + display.blit(ground_img,(0,143)) + sun_timer += 1 + if sun_timer == 16: + sun_timer = 0 + if sun_timer < 8: + display.blit(sun,sun_pos) + else: + display.blit(sun2,sun_pos) + for cloud in clouds: + display.blit(cloud_images[cloud[2]],(cloud[0],cloud[1])) + for plant in plants: + height = plant_images[plant[1]].get_height() + display.blit(plant_images[plant[1]],(plant[0],143-height)) + # Effects ------------------------------------------------ # + n = 0 + for effect in effects: + if paused == False: + effect[1] -= 1 + if effect[1] <= 0: + effects.pop(n) + n -= 1 + if effect[0] == 'rm': + spawn_rate_multipliers['meteors'] /= 2 + if effect[0] == 'rb': + spawn_rate_multipliers['bullet'] /= 2 + if effect[0] == 'qd': + spawn_rate_multipliers['cards'] *= 3 + n += 1 + # Spawns ------------------------------------------------- # + if paused == False: + for hazard in spawn_rates: + for i in range(int(spawn_rates[hazard]*spawn_rate_multipliers[hazard])): + if random.randint(1,600) == 1: + if hazard == 'meteors': + # type, x, y, x_vel, y_vel, timer + projectiles.append([random.choice(['meteor1','meteor2']),random.randint(0,200),-10,random.randint(0,2)-1,random.randint(2,3),0]) + if hazard == 'bullet': + bullet_s.play() + direction = random.choice(['r','l']) + if direction == 'r': + x = 200 + x_vel = -4 + else: + x = -20 + x_vel = 4 + projectiles.append(['bullet',x,random.randint(20,140),x_vel,0]) + if hazard == 'tumbleweed': + projectiles.append(['tumbleweed',200,random.randint(50,130),random.randint(0,1)-2,1,0]) + # Animations --------------------------------------------- # + # type, x, y, timer, timer_inc, flip + n = 0 + for anim in animations: + if anim[0] == 'jump': + try: + display.blit(jump_anim[int(anim[3])],(anim[1],anim[2])) + except IndexError: + animations.pop(n) + n -= 1 + if anim[0] == 'turn': + try: + if anim[5] == False: + display.blit(turn_anim[int(anim[3])],(anim[1],anim[2])) + else: + display.blit(flip(turn_anim[int(anim[3])]),(anim[1],anim[2])) + except IndexError: + animations.pop(n) + n -= 1 + if paused == False: + anim[3] += anim[4] + n += 1 + # Platforms ---------------------------------------------- # + for platform in platforms: + display.blit(platform_img,(platform[0],platform[1])) + # Spikes ------------------------------------------------- # + if paused == False: + if spike_timer == 0: + if random.randint(1,800) == 1: + spike_timer = 65 + else: + spike_timer -= 1 + if spike_timer > 15: + display.blit(spikes[0],(0,139)) + elif spike_timer > 6: + display.blit(spikes[2],(0,139)) + spikesR = pygame.Rect(0,139,200,4) + if spikesR.colliderect(player.obj.rect): + if invincibility == 0: + hurt_s.play() + health -= 1 + if health < 0: + health = 0 + invincibility = 30 + elif spike_timer > 3: + display.blit(spikes[1],(0,139)) + elif spike_timer > 0: + display.blit(spikes[0],(0,139)) + # Card Items --------------------------------------------- # + if paused == False: + if len(deck)-len(card_items) > 0: + time_since_card += 1 + if (random.randint(1,int(300/spawn_rate_multipliers['cards'])) == 1) or (time_since_card > 300): + x = random.randint(1,194) + y = random.randint(50,134) + dis = abs(x-player.x) + abs(y-player.y) + if dis > 20: + time_since_card = 0 + # x, y, timer, duration + card_items.append([x,y,0,400]) + card_0_s.play() + n = 0 + for card in card_items: + if (card[3] < 396) and (card[3] > 2): + display.blit(card_item_img,(card[0],card[1]+int(card[2]/20))) + else: + display.blit(card_item_img2,(card[0],card[1]+int(card[2]/20))) + popped = False + if paused == False: + card[2] += 1 + if card[2] == 40: + card[2] = 0 + card[3] -= 1 + if card[3] == 0: + card_items.pop(n) + n -= 1 + popped = True + if card[3] > 2: + if len(hand) < 5: + cardR = pygame.Rect(card[0],card[1],5,7) + if player.obj.rect.colliderect(cardR): + card[3] = 2 + n -= 1 + draw = random.randint(0,len(deck)-1) + hand.append(deck[draw]) + deck.pop(draw) + card_1_s.play() + n += 1 + # Particles ---------------------------------------------- # + n = 0 + for particle in particles: + particle[0] += particle[2] + particle[1] += particle[3] + display.set_at((int(particle[0]),int(particle[1])),particle[4]) + particle[5] -= 1 + if particle[5] <= 0: + particles.pop(n) + n -= 1 + n += 1 + # Static Images ------------------------------------------ # + n = 0 + for img in static_images: + if img[0] == 'meteor1': + display.blit(meteor_1_trail,(img[1],img[2])) + elif img[0] == 'meteor2': + display.blit(meteor_2_trail,(img[1],img[2])) + img[1] += img[4] + img[2] += img[5] + img[3] -= 1 + if img[3] <= 0: + static_images.pop(n) + n -= 1 + n += 1 + # Player ------------------------------------------------- # + if dead_timer > 0: + dead_timer -= 1 + if health < 1: + paused = False + if dead_timer == -1: + dead_timer = 80 + if speed_multiplier[0] != 1: + speed_multiplier[1] -= 1 + if speed_multiplier[1] <= 0: + speed_multiplier[0] = 1 + if paused == False: + if jump_cap[0] != 1: + jump_cap[1] -= 1 + if jump_cap[1] < 1: + jump_cap = [1,0] + if invincibility > 0: + invincibility -= 1 + air_time += 1 + player_grav += 0.25 + if player_grav > 3: + player_grav = 3 + p_momentum = [0,player_grav] + if dead_timer == -1: + if right == True: + p_momentum[0] += 2*speed_multiplier[0] + if left == True: + p_momentum[0] -= 2*speed_multiplier[0] + if paused == False: + if p_momentum[0] > 0: + if last_dir == 'l': + animations.append(['turn',player.x-2,player.y+6,0,0.5,False]) + last_dir = 'r' + elif p_momentum[0] < 0: + if last_dir == 'r': + animations.append(['turn',player.x-2,player.y+6,0,0.5,True]) + last_dir = 'l' + if paused == True: + p_momentum = [0,0] + else: + p_collisions = player.move(p_momentum,tiles) + if speed_multiplier[0] != 1: + if p_momentum[0] != 0: + if last_dir == 'r': + particles.append([player.x+2,player.y+13,-random.randint(1,2)/4,-random.randint(0,4)/4,(177,158,141),random.randint(2,3)]) + else: + particles.append([player.x+2,player.y+13,random.randint(1,2)/4,-random.randint(0,4)/4,(177,158,141),random.randint(2,3)]) + show = True + if invincibility > 0: + if random.randint(1,3) == 1: + show = False + if p_collisions['bottom'] == True: + player_grav = 0 + jumps = jump_cap[0] + air_time = 0 + player.update_animation(player_walking,player_key) + if dead_timer == -1: + if show == True: + if air_time > 3: + if last_dir == 'r': + display.blit(player_jumping,(player.x,player.y)) + else: + display.blit(flip(player_jumping),(player.x,player.y)) + else: + if p_momentum[0] > 0: + player_walking.play(player_key,display) + elif p_momentum[0] < 0: + player_walking.play(player_key,display,True) + elif last_dir == 'r': + display.blit(player_standing,(player.x,player.y)) + else: + display.blit(flip(player_standing),(player.x,player.y)) + else: + if last_dir == 'r': + display.blit(player_dead,(player.x,player.y)) + else: + display.blit(flip(player_dead),(player.x,player.y)) + if player.y < 4: + player.y = 4 + player.obj.y = 4 + player.obj.rect.y = 4 + # Circle Particles --------------------------------------- # + n = 0 + for p in circle_particles: + if paused == False: + p[0] += p[2] + p[1] += p[3] + if p[2] > 0: + p[2] -= 0.1 + elif p[2] < 0: + p[2] += 0.1 + p[3] += 0.2 + p[4] -= 0.1 + r = pygame.draw.circle(display,p[5],(int(p[0]),int(p[1])),int(p[4])) + popped = False + if player.obj.rect.colliderect(r): + if invincibility == 0: + hurt_s.play() + health -= 1 + if health < 0: + health = 0 + if invincibility < 30: + invincibility = 30 + popped = True + circle_particles.pop(n) + n -= 1 + if p[4] <= 1: + if popped == False: + circle_particles.pop(n) + n -= 1 + n += 1 + # Projectiles -------------------------------------------- # + n = 0 + for proj in projectiles: + if proj[0][:6] == 'meteor': + proj[5] += 1 + if proj[5] == 4: + proj[5] = 0 + # type, x, y, duration + if paused == False: + static_images.append([proj[0],proj[1],proj[2],2,proj[3],proj[4]]) + if proj[0][-1] == '1': + proj[0] = 'meteor2' + else: + proj[0] = 'meteor1' + if proj[0][-1] == '1': + display.blit(meteor_1,(proj[1],proj[2])) + else: + display.blit(meteor_2,(proj[1],proj[2])) + if paused == False: + proj[1] += proj[3] + proj[2] += proj[4] + projR = pygame.Rect(proj[1],proj[2],6,6) + popped = False + if projR.colliderect(player.obj.rect): + if invincibility == 0: + meteor_s.play() + hurt_s.play() + health -= 1 + if health < 0: + health = 0 + for i in range(4): + circle_particles.append([proj[1]+2,proj[2]+2,random.randint(0,4)-2,-1.7,random.randint(4,6),random.choice([(185,57,57),(119,61,60)])]) + if invincibility < 30: + invincibility = 30 + popped = True + projectiles.pop(n) + n -= 1 + for tile in tiles: + tileR = pygame.Rect(tile[0],tile[1],tile[2],tile[3]) + if tileR.colliderect(projR): + meteor_s.play() + for i in range(4): + # x, y, x_vel, y_vel, size, color + circle_particles.append([proj[1]+2,proj[2]+2,random.randint(0,4)-2,-1.7,random.randint(4,6),random.choice([(185,57,57),(119,61,60)])]) + if popped == False: + try: + projectiles.pop(n) + except: + pass + n -= 1 + if proj[0] == 'bullet': + if paused == False: + bulletR = pygame.Rect(proj[1],proj[2],6,4) + if bulletR.colliderect(player.obj.rect): + if invincibility == 0: + hurt_s.play() + health -= 1 + if health < 0: + health = 0 + if invincibility < 30: + invincibility = 30 + if proj[3] > 0: + display.blit(bullet_img,(proj[1],proj[2])) + for i in range(4): + particles.append([proj[1],proj[2]+random.randint(0,3),-(random.randint(3,6)/4),(random.randint(0,8)-4)/5,(177,158,141),random.randint(2,3)]) + if proj[1] > 200: + projectiles.pop(n) + n -= 1 + else: + display.blit(flip(bullet_img),(proj[1],proj[2])) + for i in range(4): + particles.append([proj[1]+6,proj[2]+random.randint(0,3),random.randint(3,6)/4,(random.randint(0,8)-4)/5,(177,158,141),random.randint(2,3)]) + if proj[1] < -20: + projectiles.pop(n) + n -= 1 + if paused == False: + proj[1] += proj[3] + proj[2] += proj[4] + if proj[0] == 'tumbleweed': + projR = pygame.Rect(proj[1],proj[2],8,8) + if paused == False: + proj[1] += proj[3] + proj[2] += proj[4] + proj[4] += 0.2 + bounce = False + for tile in tiles: + tileR = pygame.Rect(tile[0],tile[1],tile[2],tile[3]) + if tileR.colliderect(projR): + if bounce == False: + if proj[4] > 0: + proj[4] = -proj[4] + if proj[4] < -5: + proj[4] = -5 + bounce = True + if projR.colliderect(player.obj.rect): + if invincibility == 0: + hurt_s.play() + health -= 1 + if health < 0: + health = 0 + invincibility = 30 + proj[5] += 1 + if proj[5] == 9: + proj[5] = 0 + if proj[5] < 3: + display.blit(tumbleweed[0],(proj[1],proj[2])) + elif proj[5] < 6: + display.blit(tumbleweed[1],(proj[1],proj[2])) + else: + display.blit(tumbleweed[2],(proj[1],proj[2])) + if proj[1] < -20: + projectiles.pop(n) + n -= 1 + n += 1 + # UI ----------------------------------------------------- # + for x in range(health): + display.blit(heart,(2+x*7,2)) + + display.blit(score_box,(175,2)) + text.show_text(str(score) + '/' + str(goal),181,7,1,185,font_2,display) + + + overlay_surf = pygame.Surface((200,150)) + + if paused == False: + if pause_cooldown > 0: + pause_cooldown -= 1 + good = True + for card in card_visuals: + if card[2] < 150: + good = False + if good == True: + card_visuals = [] + hovered_card = 0 + elif card_visuals == []: + x = 0.05 + for card in hand: + # id, x, y + card_visuals.append([card,x*40,150]) + x += 1 + + n = 0 + for card in card_visuals: + overlay_surf.blit(card_back,(card[1],int(card[2]))) + overlay_surf.blit(card_images[card[0]],(card[1],int(card[2]))) + if paused == True: + target_y = 120 + if n == hovered_card: + target_y = 90 + display.blit(card_back,(card[1],int(card[2]))) + display.blit(card_images[card[0]],(card[1],int(card[2]))) + else: + target_y = 160 + card[2] += (target_y-card[2])/6 + n += 1 + if card_visuals != []: + overlay_surf.blit(description,(box_pos,39)) + text.show_text(card_visuals[hovered_card][0],box_pos+5,44,1,185,font_2,overlay_surf) + if paused == False: + target_x = 220 + else: + target_x = 82 + box_pos += (target_x-box_pos)/4 + if paused == False: + target_x = -80 + else: + target_x = 4 + instructions_target = 220 + if moved == False: + instructions_target = 50 + instructions_pos += (instructions_target-instructions_pos)/6 + display.blit(instructions_img,(instructions_pos,26)) + target = 210 + if level == 1: + if hand != []: + if z_pressed == False: + target = 180 + z_pos += (target-z_pos)/6 + display.blit(z_img,(z_pos,76)) + cancel_pos += (target_x-cancel_pos)/6 + select_pos += (target_x-select_pos)/4 + overlay_surf.blit(cancel,(cancel_pos,60)) + overlay_surf.blit(select,(select_pos,40)) + overlay_surf.set_colorkey((0,0,0)) + overlay_surf.set_alpha(200) + display.blit(overlay_surf,(0,0)) + death_pos += (death_target-death_pos)/4 + display.blit(death_img,(80,death_pos)) + + if level_name[1] < 60: + if level_name[1] < 10: + opacity = level_name[1]*25.5 + elif level_name[1] > 50: + opacity = 255-(level_name[1]-50)*25.5 + else: + opacity = 255 + surf = pygame.Surface((200,150)) + surf.set_colorkey((0,0,0)) + surf.set_alpha(opacity) + text.show_text(level_name[0],100-int(len(level_name[0])/2)*4,50,1,185,font,surf) + display.blit(surf,(0,0)) + level_name[1] += 1 + + if fade > 0: + fade -= 25 + fade_surf = pygame.Surface((200,150)) + fade_surf.fill((219,210,202)) + fade_surf.set_alpha(fade) + display.blit(fade_surf,(0,0)) + # Buttons ------------------------------------------------ # + for event in pygame.event.get(): + if event.type == QUIT: + pygame.quit() + sys.exit() + if event.type == KEYDOWN: + if event.key == K_RIGHT: + right = True + if paused == True: + hovered_card += 1 + if hovered_card > len(card_visuals)-1: + hovered_card = len(card_visuals)-1 + else: + card_1_s.play() + moved = True + if event.key == K_LEFT: + left = True + if paused == True: + hovered_card -= 1 + if hovered_card < 0: + hovered_card = 0 + else: + card_1_s.play() + moved = True + if event.key == K_UP: + if dead_timer == -1: + if jumps > 0: + animations.append(['jump',player.x-2,player.y+6,0,0.5,False]) + jumps -= 1 + player_grav = -5 + air_time = 4 + moved = True + if event.key == K_z: + if hand != []: + z_pressed = True + if paused == False: + if pause_cooldown == 0: + paused = True + pause_cooldown = 40 + else: + paused = False + if event.key == K_x: + if paused == True: + if hand != []: + card_1_s.play() + used = hand[hovered_card] + if used == '1 point': + score += 1 + elif used == 'double jump 5s': + jump_cap = [2,200] + jumps += 1 + elif used == 'heal': + health += 1 + if health > 3: + health = 3 + elif used == 'invincible 3s': + invincibility += 120 + elif used == 'reduce meteorites 10s': + effects.append(['rm',400]) + elif used == 'reduce bullets 10s': + effects.append(['rb',400]) + elif used == 'quick draw 5s': + effects.append(['qd',200]) + elif used == 'platform': + platforms.append([player.x-8,player.y-10,25,7]) + elif used == 'triple jump 10s': + jump_cap = [3,400] + jumps += 2 + elif used == 'speed 5s': + speed_multiplier = [1.5,200] + hand.pop(hovered_card) + paused = False + if event.type == KEYUP: + if event.key == K_RIGHT: + right = False + if event.key == K_LEFT: + left = False + # Update ------------------------------------------------- # + screen.blit(pygame.transform.scale(display,(WINDOWWIDTH,WINDOWHEIGHT)),(0,0)) + pygame.display.update() + mainClock.tick(40) + # Level Transition --------------------------------------- # + if score == goal: + invincible = 2 + pick_stage = 0 + if card_visuals == []: + card_options = [] + for card in card_chances: + for i in range(card_chances[card]): + card_options.append(card) + new_cards = [random.choice(card_options),random.choice(card_options)] + swap_cards = [] + while len(swap_cards) < 3: + swap = random.choice(cards) + if swap != '1 point': + swap_cards.append(swap) + else: + c = 0 + for card in cards: + if card == '1 point': + c += 1 + if c >= 6: + swap_cards.append(swap) + transition = True + screenshot = display.copy() + t = 0 + info_pos = -30 + info_target = -30 + desc_pos = 200 + desc_target = 220 + pygame.mixer.music.set_volume(0.2) + while transition: + if hovered_card < 0: + hovered_card = 0 + display.blit(screenshot,(0,0)) + fade_surf = pygame.Surface((200,150)) + fade_surf.fill((219,210,202)) + fade_surf.set_alpha(t) + t += 5 + if t > 255: + t = 255 + if pick_stage == 0: + pick_stage = 1 + card_visuals = [] + for card in new_cards: + card_visuals.append([card,150]) + hovered_card = 0 + display.blit(fade_surf,(0,0)) + if pick_stage == 1: + info_target = 2 + desc_target = 50 + display.blit(description,(50,info_pos)) + text.show_text('Choose a new card.',55,info_pos+5,1,200,font_2,display) + n = 0 + for card in card_visuals: + target = 120 + if n == hovered_card: + target = 90 + card[1] += (target-card[1])/5 + display.blit(card_back,(60 + n * 40, card[1])) + display.blit(card_images[card[0]],(60 + n * 40, card[1])) + n += 1 + elif pick_stage == 2: + info_target = 2 + display.blit(description,(50,info_pos)) + text.show_text('Choose a new card.',55,info_pos+5,1,200,font_2,display) + n = 0 + for card in card_visuals: + target = 160 + card[1] += (target-card[1])/5 + display.blit(card_back,(60 + n * 40, card[1])) + display.blit(card_images[card[0]],(60 + n * 40, card[1])) + n += 1 + done = True + for card in card_visuals: + if card[1] < 150: + done = False + if done == True: + pick_stage = 3 + card_visuals = [] + for card in swap_cards: + card_visuals.append([card,150]) + hovered_card = 0 + elif pick_stage == 3: + info_target = 2 + display.blit(description,(50,info_pos)) + text.show_text('Choose a card to lose.',55,info_pos+5,1,200,font_2,display) + n = 0 + for card in card_visuals: + target = 120 + if n == hovered_card: + target = 90 + card[1] += (target-card[1])/5 + display.blit(card_back,(40 + n * 40, card[1])) + display.blit(card_images[card[0]],(40 + n * 40, card[1])) + n += 1 + elif pick_stage == 4: + info_target = -30 + display.blit(description,(50,info_pos)) + text.show_text('Choose a card to lose.',55,info_pos+5,1,200,font_2,display) + n = 0 + desc_target = 220 + for card in card_visuals: + target = 160 + card[1] += (target-card[1])/5 + display.blit(card_back,(40 + n * 40, card[1])) + display.blit(card_images[card[0]],(40 + n * 40, card[1])) + n += 1 + done = True + for card in card_visuals: + if card[1] < 150: + done = False + if done == True: + pick_stage = 5 + info_pos += (info_target-info_pos)/4 + desc_pos += (desc_target-desc_pos)/3 + display.blit(description,(desc_pos,60)) + if len(card_visuals) > hovered_card: + text.show_text(card_visuals[hovered_card][0],desc_pos+5,65,1,200,font_2,display) + for event in pygame.event.get(): + if event.type == QUIT: + pygame.quit() + sys.exit() + if event.type == KEYDOWN: + if event.key == K_RIGHT: + hovered_card += 1 + if hovered_card > len(card_visuals)-1: + hovered_card = len(card_visuals)-1 + else: + card_1_s.play() + if event.key == K_LEFT: + hovered_card -= 1 + if hovered_card < 0: + hovered_card = 0 + else: + card_1_s.play() + if event.key == K_x: + if pick_stage == 1: + new_card = card_visuals[hovered_card][0] + pick_stage = 2 + card_1_s.play() + elif pick_stage == 3: + remove_card = card_visuals[hovered_card][0] + pick_stage = 4 + card_1_s.play() + screen.blit(pygame.transform.scale(display,(WINDOWWIDTH,WINDOWHEIGHT)),(0,0)) + pygame.display.update() + mainClock.tick(40) + if pick_stage == 5: + transition = False + cards.remove(remove_card) + cards.append(new_card) + card_visuals = [] + paused = False + pause_cooldown = 0 + health = 3 + plants = generate_plants(plant_images) + clouds = generate_clouds(cloud_images) + projectiles = [] + static_images = [] + circle_particles = [] + deck = cards.copy() + hand = [] + effects = [] + dead_timer = -1 + goal = 3 + card_items = [] + platforms = [] + speed_multiplier = [1,0] + death_target = -30 + score = 0 + fade = 255 + level += 1 + animations = [] + spike_timer = 0 + spawn_rates['meteors'] += 1 + spawn_rates['bullet'] += 1 + right = False + left = False + pygame.mixer.music.set_volume(0.45) + if level % 3 == 1: + level_name = ['10:00AM - Day ' + str(int((level-(level%3))/3+1)),0] + elif level % 3 == 2: + level_name = ['11:00AM',0] + else: + level_name = ['High Noon',0] + spawn_rates['meteors'] += 2 + spawn_rates['bullet'] += 1 + spawn_rates['tumbleweed'] += 1 + # Death -------------------------------------------------- # + if dead_timer == 0: + dead = True + screenshot = display.copy() + t = 0 + pygame.mixer.music.set_volume(0.2) + while dead: + display.blit(screenshot,(0,0)) + fade_surf = pygame.Surface((200,150)) + fade_surf.fill((219,210,202)) + fade_surf.set_alpha(t) + t += 5 + if t > 255: + t = 255 + display.blit(fade_surf,(0,0)) + for event in pygame.event.get(): + if event.type == QUIT: + pygame.quit() + sys.exit() + if event.type == KEYDOWN: + dead = False + if event.type == MOUSEBUTTONDOWN: + dead = False + death_target = 50 + death_pos += (death_target-death_pos)/4 + display.blit(death_img,(80,death_pos)) + screen.blit(pygame.transform.scale(display,(WINDOWWIDTH,WINDOWHEIGHT)),(0,0)) + pygame.display.update() + mainClock.tick(40) + spawn_rates = base_spawn_rates.copy() + paused = False + pause_cooldown = 0 + health = 3 + cards = base_cards.copy() + spawn_rates = base_spawn_rates.copy() + plants = generate_plants(plant_images) + clouds = generate_clouds(cloud_images) + projectiles = [] + static_images = [] + circle_particles = [] + deck = cards.copy() + hand = [] + effects = [] + dead_timer = -1 + goal = 3 + card_items = [] + platforms = [] + speed_multiplier = [1,0] + death_target = -30 + score = 0 + fade = 255 + right = False + left = False + level = 1 + animations = [] + level_name = ['10:00AM - Day 1',0] + spike_timer = 0 + pygame.mixer.music.set_volume(0.45) + diff --git a/data/fonts/small_font.png b/data/fonts/small_font.png new file mode 100644 index 0000000000000000000000000000000000000000..91cd3453e381e5c2d32d248e1890e0bc53a252c2 Binary files /dev/null and b/data/fonts/small_font.png differ diff --git a/data/images/bullet.png b/data/images/bullet.png new file mode 100644 index 0000000000000000000000000000000000000000..c8b90ec83e409494798541dcc39206369e044a74 Binary files /dev/null and b/data/images/bullet.png differ diff --git a/data/images/cancel.png b/data/images/cancel.png new file mode 100644 index 0000000000000000000000000000000000000000..e81aceefb240e8066c3a1854d9231543d21d7456 Binary files /dev/null and b/data/images/cancel.png differ diff --git a/data/images/card.png b/data/images/card.png new file mode 100644 index 0000000000000000000000000000000000000000..e5e9a8a7c4378505b2346e49276ea53cbe7d50f0 Binary files /dev/null and b/data/images/card.png differ diff --git a/data/images/card2.png b/data/images/card2.png new file mode 100644 index 0000000000000000000000000000000000000000..c0a578f4003b7b6d7736171f9c242bca6ef731e7 Binary files /dev/null and b/data/images/card2.png differ diff --git a/data/images/card_back.png b/data/images/card_back.png new file mode 100644 index 0000000000000000000000000000000000000000..7c7b0303baa94e00508700c799ba669b84f77186 Binary files /dev/null and b/data/images/card_back.png differ diff --git a/data/images/cards/1 point.png b/data/images/cards/1 point.png new file mode 100644 index 0000000000000000000000000000000000000000..2b776561eba377bd24479f5058651c24dd2bf36c Binary files /dev/null and b/data/images/cards/1 point.png differ diff --git a/data/images/cards/double jump 5s.png b/data/images/cards/double jump 5s.png new file mode 100644 index 0000000000000000000000000000000000000000..2eefa67306660998ee47080d233e1c4b53eebd31 Binary files /dev/null and b/data/images/cards/double jump 5s.png differ diff --git a/data/images/cards/heal.png b/data/images/cards/heal.png new file mode 100644 index 0000000000000000000000000000000000000000..7c821893adaa780a1f774070233e518d4d6e2b9e Binary files /dev/null and b/data/images/cards/heal.png differ diff --git a/data/images/cards/invincible 3s.png b/data/images/cards/invincible 3s.png new file mode 100644 index 0000000000000000000000000000000000000000..4026b108bf8924b68cbe51cb6447c43fd07b98a2 Binary files /dev/null and b/data/images/cards/invincible 3s.png differ diff --git a/data/images/cards/platform.png b/data/images/cards/platform.png new file mode 100644 index 0000000000000000000000000000000000000000..f8bb98273cf068bcc75d729dd24de664a5e7ed79 Binary files /dev/null and b/data/images/cards/platform.png differ diff --git a/data/images/cards/quick draw 5s.png b/data/images/cards/quick draw 5s.png new file mode 100644 index 0000000000000000000000000000000000000000..0f60fc4da6432fe922ce0bb8302c9f07c7c7c136 Binary files /dev/null and b/data/images/cards/quick draw 5s.png differ diff --git a/data/images/cards/reduce bullets 10s.png b/data/images/cards/reduce bullets 10s.png new file mode 100644 index 0000000000000000000000000000000000000000..64d2c1bf2a7e764aaa2c6b0677aa179ba9f0b6f6 Binary files /dev/null and b/data/images/cards/reduce bullets 10s.png differ diff --git a/data/images/cards/reduce meteorites 10s.png b/data/images/cards/reduce meteorites 10s.png new file mode 100644 index 0000000000000000000000000000000000000000..33b4738f5fa9194b24eb8c33731aaa9d7618d07e Binary files /dev/null and b/data/images/cards/reduce meteorites 10s.png differ diff --git a/data/images/cards/speed 5s.png b/data/images/cards/speed 5s.png new file mode 100644 index 0000000000000000000000000000000000000000..8054e349f1322a182f4d5299f19b256d2fd4e0ee Binary files /dev/null and b/data/images/cards/speed 5s.png differ diff --git a/data/images/cards/triple jump 10s.png b/data/images/cards/triple jump 10s.png new file mode 100644 index 0000000000000000000000000000000000000000..fe1466107b6f0dd70f4bffa35c22b71fef00d4df Binary files /dev/null and b/data/images/cards/triple jump 10s.png differ diff --git a/data/images/cloud_0.png b/data/images/cloud_0.png new file mode 100644 index 0000000000000000000000000000000000000000..c18db061c631deeddb391e5e9b88be4ec23d3954 Binary files /dev/null and b/data/images/cloud_0.png differ diff --git a/data/images/cloud_1.png b/data/images/cloud_1.png new file mode 100644 index 0000000000000000000000000000000000000000..13c44745dfda8fbc44a6efb5ccb7c405e98e1f56 Binary files /dev/null and b/data/images/cloud_1.png differ diff --git a/data/images/cloud_2.png b/data/images/cloud_2.png new file mode 100644 index 0000000000000000000000000000000000000000..6cee30baf7762488e1232007323cc55a0bdfa1a1 Binary files /dev/null and b/data/images/cloud_2.png differ diff --git a/data/images/cloud_3.png b/data/images/cloud_3.png new file mode 100644 index 0000000000000000000000000000000000000000..bb0930f2e6a7664e30ba26e7ec0c89cc5b93f48f Binary files /dev/null and b/data/images/cloud_3.png differ diff --git a/data/images/death.png b/data/images/death.png new file mode 100644 index 0000000000000000000000000000000000000000..8b4746dded1c3432d23a4a8440bb6b6307d562a6 Binary files /dev/null and b/data/images/death.png differ diff --git a/data/images/description.png b/data/images/description.png new file mode 100644 index 0000000000000000000000000000000000000000..07e15c0e8161fb0b76afae1962a1dc89c89ce508 Binary files /dev/null and b/data/images/description.png differ diff --git a/data/images/ground.png b/data/images/ground.png new file mode 100644 index 0000000000000000000000000000000000000000..95faa0921e222656ec586b01f3cbc7911288a779 Binary files /dev/null and b/data/images/ground.png differ diff --git a/data/images/heart.png b/data/images/heart.png new file mode 100644 index 0000000000000000000000000000000000000000..7e101f1fd68ed64160495a7cf1d50186ea8ebc7f Binary files /dev/null and b/data/images/heart.png differ diff --git a/data/images/instructions.png b/data/images/instructions.png new file mode 100644 index 0000000000000000000000000000000000000000..30730b35e7619e9a7b02264d1c6dbf7c6cae97f8 Binary files /dev/null and b/data/images/instructions.png differ diff --git a/data/images/meteor_1.png b/data/images/meteor_1.png new file mode 100644 index 0000000000000000000000000000000000000000..197614812fca0cebec38240a0b4b2daed117da03 Binary files /dev/null and b/data/images/meteor_1.png differ diff --git a/data/images/meteor_1_trail.png b/data/images/meteor_1_trail.png new file mode 100644 index 0000000000000000000000000000000000000000..746e6d163c8c354f9d594db3a7d613cf52692814 Binary files /dev/null and b/data/images/meteor_1_trail.png differ diff --git a/data/images/meteor_2.png b/data/images/meteor_2.png new file mode 100644 index 0000000000000000000000000000000000000000..1ff27784f82460e24aeadc68f2280b3c25bff3e8 Binary files /dev/null and b/data/images/meteor_2.png differ diff --git a/data/images/meteor_2_trail.png b/data/images/meteor_2_trail.png new file mode 100644 index 0000000000000000000000000000000000000000..6101e5d3e945bc7d51024801be6e7764f8eaffc1 Binary files /dev/null and b/data/images/meteor_2_trail.png differ diff --git a/data/images/mockup.png b/data/images/mockup.png new file mode 100644 index 0000000000000000000000000000000000000000..1dcc4987d857c8f73670b3ab1ce36bafb7b25f38 Binary files /dev/null and b/data/images/mockup.png differ diff --git a/data/images/palette.png b/data/images/palette.png new file mode 100644 index 0000000000000000000000000000000000000000..5a5a7a89d34adc0b7385a8c8eab17dabd5755a6a Binary files /dev/null and b/data/images/palette.png differ diff --git a/data/images/plant_0.png b/data/images/plant_0.png new file mode 100644 index 0000000000000000000000000000000000000000..915de1e0fcc64ca572da2605b4506f3325c76d47 Binary files /dev/null and b/data/images/plant_0.png differ diff --git a/data/images/plant_1.png b/data/images/plant_1.png new file mode 100644 index 0000000000000000000000000000000000000000..73dfa3b6d1ed4efcb20a343c9ad6391ed6fe7990 Binary files /dev/null and b/data/images/plant_1.png differ diff --git a/data/images/plant_2.png b/data/images/plant_2.png new file mode 100644 index 0000000000000000000000000000000000000000..96d59958b584f576661caaeb78c42645069e1e5a Binary files /dev/null and b/data/images/plant_2.png differ diff --git a/data/images/plant_3.png b/data/images/plant_3.png new file mode 100644 index 0000000000000000000000000000000000000000..6ecb61f3cb56f666819ea0f465b143fc0fa4e406 Binary files /dev/null and b/data/images/plant_3.png differ diff --git a/data/images/plant_4.png b/data/images/plant_4.png new file mode 100644 index 0000000000000000000000000000000000000000..bac0b38a165bc041a046c319fef5933c79cb6a97 Binary files /dev/null and b/data/images/plant_4.png differ diff --git a/data/images/platform.png b/data/images/platform.png new file mode 100644 index 0000000000000000000000000000000000000000..a8334f525fa3d1598dcef2c19210d6c919f8bd3b Binary files /dev/null and b/data/images/platform.png differ diff --git a/data/images/player/dead.png b/data/images/player/dead.png new file mode 100644 index 0000000000000000000000000000000000000000..7def0d4d79864550ba6f369e761971af8c939830 Binary files /dev/null and b/data/images/player/dead.png differ diff --git a/data/images/player/jumping.png b/data/images/player/jumping.png new file mode 100644 index 0000000000000000000000000000000000000000..ae42af75541a69c7ca681a96fd7cb6d03b6b0870 Binary files /dev/null and b/data/images/player/jumping.png differ diff --git a/data/images/player/standing.png b/data/images/player/standing.png new file mode 100644 index 0000000000000000000000000000000000000000..36996eccd22f83d7b14b7f9fc2bb07e9fc785e4c Binary files /dev/null and b/data/images/player/standing.png differ diff --git a/data/images/player/walking/walking_0.png b/data/images/player/walking/walking_0.png new file mode 100644 index 0000000000000000000000000000000000000000..82ac4af2ae2f1ddbc2c2dcfb2119d7cfc9e22f3c Binary files /dev/null and b/data/images/player/walking/walking_0.png differ diff --git a/data/images/player/walking/walking_1.png b/data/images/player/walking/walking_1.png new file mode 100644 index 0000000000000000000000000000000000000000..9fd2f42bcb8bf9400d89a36ee8e4c06aa4da0e48 Binary files /dev/null and b/data/images/player/walking/walking_1.png differ diff --git a/data/images/player/walking/walking_2.png b/data/images/player/walking/walking_2.png new file mode 100644 index 0000000000000000000000000000000000000000..98bd4f883e75d836d02c115ee820eeffabeb0b27 Binary files /dev/null and b/data/images/player/walking/walking_2.png differ diff --git a/data/images/player/walking/walking_3.png b/data/images/player/walking/walking_3.png new file mode 100644 index 0000000000000000000000000000000000000000..ab566b254a14f209510c42c6df3b296449b46cb5 Binary files /dev/null and b/data/images/player/walking/walking_3.png differ diff --git a/data/images/player_walking.pxe b/data/images/player_walking.pxe new file mode 100644 index 0000000000000000000000000000000000000000..9ab1617eb96cbbb62ef9a79e85a7bf20dc14841a Binary files /dev/null and b/data/images/player_walking.pxe differ diff --git a/data/images/score_box.png b/data/images/score_box.png new file mode 100644 index 0000000000000000000000000000000000000000..b230b047538d16d12e96f2dab73488ee8b23871c Binary files /dev/null and b/data/images/score_box.png differ diff --git a/data/images/select.png b/data/images/select.png new file mode 100644 index 0000000000000000000000000000000000000000..6b979495c69662bb7663e279e8bf94487f207b9a Binary files /dev/null and b/data/images/select.png differ diff --git a/data/images/spikes_1.png b/data/images/spikes_1.png new file mode 100644 index 0000000000000000000000000000000000000000..fa3285922b2284c19a5fdab51ecefe294c1492d6 Binary files /dev/null and b/data/images/spikes_1.png differ diff --git a/data/images/spikes_2.png b/data/images/spikes_2.png new file mode 100644 index 0000000000000000000000000000000000000000..3a5cf3bf1d7f0f90b8b7a7cea796c42bed0c53c1 Binary files /dev/null and b/data/images/spikes_2.png differ diff --git a/data/images/spikes_3.png b/data/images/spikes_3.png new file mode 100644 index 0000000000000000000000000000000000000000..dcec0d61aff83415413d720bcd35456c6a942273 Binary files /dev/null and b/data/images/spikes_3.png differ diff --git a/data/images/sun.png b/data/images/sun.png new file mode 100644 index 0000000000000000000000000000000000000000..14fa1e2ba2588bd1f7e9738cf45729734e585923 Binary files /dev/null and b/data/images/sun.png differ diff --git a/data/images/sun2.png b/data/images/sun2.png new file mode 100644 index 0000000000000000000000000000000000000000..1492a43032578e67665bfdb845d1a79300d5a01f Binary files /dev/null and b/data/images/sun2.png differ diff --git a/data/images/tumbleweed_1.png b/data/images/tumbleweed_1.png new file mode 100644 index 0000000000000000000000000000000000000000..b99de974f3191122336e6f5e72beb146808f1e4c Binary files /dev/null and b/data/images/tumbleweed_1.png differ diff --git a/data/images/tumbleweed_2.png b/data/images/tumbleweed_2.png new file mode 100644 index 0000000000000000000000000000000000000000..1363c70fb0347c9a01a304541e65288df06ba4a7 Binary files /dev/null and b/data/images/tumbleweed_2.png differ diff --git a/data/images/tumbleweed_3.png b/data/images/tumbleweed_3.png new file mode 100644 index 0000000000000000000000000000000000000000..88d04b08df16c4f9e94232fdecf7453f8a964ecd Binary files /dev/null and b/data/images/tumbleweed_3.png differ diff --git a/data/images/vfx/jump/0.png b/data/images/vfx/jump/0.png new file mode 100644 index 0000000000000000000000000000000000000000..932263cf66572232d080672271c9806ac5d28b35 Binary files /dev/null and b/data/images/vfx/jump/0.png differ diff --git a/data/images/vfx/jump/1.png b/data/images/vfx/jump/1.png new file mode 100644 index 0000000000000000000000000000000000000000..7d0e28012efea4c58c16085c94b947d2dc349cd8 Binary files /dev/null and b/data/images/vfx/jump/1.png differ diff --git a/data/images/vfx/jump/2.png b/data/images/vfx/jump/2.png new file mode 100644 index 0000000000000000000000000000000000000000..4c6148f6d08b99afffbe0102aaa41e21f2b857ef Binary files /dev/null and b/data/images/vfx/jump/2.png differ diff --git a/data/images/vfx/jump/3.png b/data/images/vfx/jump/3.png new file mode 100644 index 0000000000000000000000000000000000000000..83b0f7760c9bae831e1b83dc85f4e3e95f1d3a84 Binary files /dev/null and b/data/images/vfx/jump/3.png differ diff --git a/data/images/vfx/jump/4.png b/data/images/vfx/jump/4.png new file mode 100644 index 0000000000000000000000000000000000000000..14899706da9e123d4d3f55d23f18e7d260c443f0 Binary files /dev/null and b/data/images/vfx/jump/4.png differ diff --git a/data/images/vfx/jump/5.png b/data/images/vfx/jump/5.png new file mode 100644 index 0000000000000000000000000000000000000000..aec0c1fd02182607d46c368b5dae3ba3205ec1ef Binary files /dev/null and b/data/images/vfx/jump/5.png differ diff --git a/data/images/vfx/jump/6.png b/data/images/vfx/jump/6.png new file mode 100644 index 0000000000000000000000000000000000000000..aec0c1fd02182607d46c368b5dae3ba3205ec1ef Binary files /dev/null and b/data/images/vfx/jump/6.png differ diff --git a/data/images/vfx/turn/0.png b/data/images/vfx/turn/0.png new file mode 100644 index 0000000000000000000000000000000000000000..18664f260490d95f918f57779ed92c3388d8cf69 Binary files /dev/null and b/data/images/vfx/turn/0.png differ diff --git a/data/images/vfx/turn/1.png b/data/images/vfx/turn/1.png new file mode 100644 index 0000000000000000000000000000000000000000..bb609e2f2b1a6f95cd8bb230e8cff00c687cabef Binary files /dev/null and b/data/images/vfx/turn/1.png differ diff --git a/data/images/vfx/turn/2.png b/data/images/vfx/turn/2.png new file mode 100644 index 0000000000000000000000000000000000000000..61c3899e02249a21d6924465896ef8869a2e434e Binary files /dev/null and b/data/images/vfx/turn/2.png differ diff --git a/data/images/vfx/turn/3.png b/data/images/vfx/turn/3.png new file mode 100644 index 0000000000000000000000000000000000000000..c84cfcab036a6937dc159291357f7b0a3873811e Binary files /dev/null and b/data/images/vfx/turn/3.png differ diff --git a/data/images/vfx/turn/4.png b/data/images/vfx/turn/4.png new file mode 100644 index 0000000000000000000000000000000000000000..577fb2ae229d6f4747cd991495f86e9c3db5e032 Binary files /dev/null and b/data/images/vfx/turn/4.png differ diff --git a/data/images/vfx/turn/5.png b/data/images/vfx/turn/5.png new file mode 100644 index 0000000000000000000000000000000000000000..c96f906fa5fc9e12bf03ba64ea195a18bf498dfe Binary files /dev/null and b/data/images/vfx/turn/5.png differ diff --git a/data/images/x.png b/data/images/x.png new file mode 100644 index 0000000000000000000000000000000000000000..96ab9e606878effbed8444e22c5fc8193f49fdd6 Binary files /dev/null and b/data/images/x.png differ diff --git a/data/images/z.png b/data/images/z.png new file mode 100644 index 0000000000000000000000000000000000000000..840ee3d648856ac67f6a72daf54c8f04beeb793a Binary files /dev/null and b/data/images/z.png differ diff --git a/data/music/main.ceol b/data/music/main.ceol new file mode 100644 index 0000000000000000000000000000000000000000..ce763635ea935100ec7540023fac88a2159c3559 --- /dev/null +++ b/data/music/main.ceol @@ -0,0 +1 @@ +3,0,0,0,100,16,4,4,105,0,3,128,0,256,134,0,1,128,0,256,364,2,20,128,0,142,363,1,20,128,0,204,11,7,0,0,3,16,54,1,0,0,54,1,1,0,54,1,2,0,54,1,4,0,54,1,5,0,42,1,7,0,54,1,6,0,54,1,8,0,54,1,9,0,54,1,10,0,54,1,12,0,54,1,13,0,54,1,14,0,42,1,15,0,42,1,8,0,42,1,0,0,0,7,0,1,1,5,66,4,0,0,67,1,8,0,67,1,10,0,70,4,4,0,66,4,12,0,0,7,0,1,1,12,67,1,8,0,67,1,10,0,70,4,4,0,66,1,0,0,64,1,8,0,64,1,10,0,66,4,12,0,62,4,12,0,67,4,4,0,55,1,2,0,59,1,3,0,66,1,1,0,0,7,0,0,3,16,47,1,0,0,48,1,1,0,47,1,8,0,48,1,9,0,45,2,2,0,47,1,4,0,48,1,5,0,45,2,10,0,47,1,12,0,48,1,13,0,42,2,6,0,42,2,14,0,54,2,12,0,54,2,8,0,54,2,4,0,54,2,0,0,0,7,0,1,1,15,66,1,0,0,67,1,1,0,67,1,4,0,66,1,8,0,67,1,9,0,70,1,5,0,59,1,10,0,55,1,6,0,59,1,7,0,55,1,2,0,62,1,3,0,66,4,12,0,54,1,10,0,55,1,11,0,50,1,11,0,0,7,0,0,3,18,54,1,0,0,54,1,1,0,54,1,2,0,54,1,4,0,54,1,5,0,54,1,6,0,54,1,8,0,54,1,9,0,54,1,10,0,54,1,12,0,54,1,13,0,54,1,14,0,55,1,7,0,55,1,15,0,55,1,3,0,55,1,11,0,60,1,3,0,60,1,11,0,0,7,0,0,3,12,47,1,0,0,48,1,1,0,47,1,8,0,48,1,9,0,45,2,2,0,47,1,4,0,48,1,5,0,45,2,10,0,47,1,12,0,48,1,13,0,42,2,6,0,42,2,14,0,0,0,0,2,20,8,28,1,0,0,28,1,4,0,28,1,1,0,28,1,5,0,28,1,8,0,28,1,10,0,28,1,12,0,28,1,13,0,0,0,0,2,20,4,12,1,0,0,12,1,4,0,12,1,8,0,12,1,12,0,0,0,0,2,20,6,3,1,2,0,3,1,3,0,3,1,4,0,3,1,5,0,3,1,1,0,3,1,0,0,0,0,0,3,20,16,0,1,0,0,0,1,4,0,0,1,8,0,0,1,12,0,2,1,0,0,2,1,4,0,2,1,8,0,2,1,12,0,2,1,1,0,2,1,5,0,2,1,9,0,2,1,13,0,7,1,2,0,7,1,6,0,7,1,10,0,7,1,14,0,0,11,0,11,0,-1,7,8,9,-1,-1,-1,0,1,-1,8,-1,-1,-1,-1,6,4,7,8,-1,-1,-1,-1,6,2,-1,8,-1,-1,-1,-1,6,4,7,8,-1,-1,-1,-1,5,4,7,8,-1,10,-1,-1,5,4,7,8,-1,10,-1,-1,5,4,7,8,-1,10,-1,-1,3,1,-1,8,-1,-1,-1,-1,3,-1,-1,8,9,-1,-1,-1,3,-1,-1,8,9,-1,-1,-1, \ No newline at end of file diff --git a/data/music/main.wav b/data/music/main.wav new file mode 100644 index 0000000000000000000000000000000000000000..ad6f49fbe03560cc50f9e58284fefc0c7767cab6 Binary files /dev/null and b/data/music/main.wav differ diff --git a/data/sfx/bullet.wav b/data/sfx/bullet.wav new file mode 100644 index 0000000000000000000000000000000000000000..142e1648a7f8957459bf2a44409522fbe64ebd40 Binary files /dev/null and b/data/sfx/bullet.wav differ diff --git a/data/sfx/card_0.wav b/data/sfx/card_0.wav new file mode 100644 index 0000000000000000000000000000000000000000..9e393d1467acd8e55edea1e883fd454e7642ade0 Binary files /dev/null and b/data/sfx/card_0.wav differ diff --git a/data/sfx/card_1.wav b/data/sfx/card_1.wav new file mode 100644 index 0000000000000000000000000000000000000000..19d151801eb33392f7b82f18535df7163fae7b24 Binary files /dev/null and b/data/sfx/card_1.wav differ diff --git a/data/sfx/hurt.wav b/data/sfx/hurt.wav new file mode 100644 index 0000000000000000000000000000000000000000..5c4489d444f557914e0f09a1d9252718f94972ec Binary files /dev/null and b/data/sfx/hurt.wav differ diff --git a/data/sfx/meteor.wav b/data/sfx/meteor.wav new file mode 100644 index 0000000000000000000000000000000000000000..b8342d0e5a6a06b8856e532498f4dba98a3fbdea Binary files /dev/null and b/data/sfx/meteor.wav differ diff --git a/entities.py b/entities.py new file mode 100644 index 0000000000000000000000000000000000000000..14d55fa5db57364402cfc25c6fce539735f51448 --- /dev/null +++ b/entities.py @@ -0,0 +1,228 @@ +import pygame +from pygame.locals import * + +# physics +def CollisionTest(Object1,ObjectList): + CollisionList = [] + for Object in ObjectList: + ObjectRect = pygame.Rect(Object[0],Object[1],Object[2],Object[3]) + if ObjectRect.colliderect(Object1): + CollisionList.append(ObjectRect) + return CollisionList + +class PhysicsObject(object): + + def __init__(self,x,y,x_size,y_size): + self.width = x_size + self.height = y_size + self.rect = pygame.Rect(x,y,self.width,self.height) + self.x = x + self.y = y + + def Move(self,Movement,platforms): + self.x += Movement[0] + self.rect.x = int(self.x) + block_hit_list = CollisionTest(self.rect,platforms) + collision_types = {'top':False,'bottom':False,'right':False,'left':False} + for block in block_hit_list: + if Movement[0] > 0: + self.rect.right = block.left + collision_types['right'] = True + elif Movement[0] < 0: + self.rect.left = block.right + collision_types['left'] = True + self.x = self.rect.x + self.y += Movement[1] + self.rect.y = int(self.y) + block_hit_list = CollisionTest(self.rect,platforms) + for block in block_hit_list: + if Movement[1] > 0: + self.rect.bottom = block.top + collision_types['bottom'] = True + elif Movement[1] < 0: + self.rect.top = block.bottom + collision_types['top'] = True + self.change_y = 0 + self.y = self.rect.y + return collision_types + + def Draw(self): + pygame.draw.rect(screen,(0,0,255),self.rect) + + def CollisionItem(self): + CollisionInfo = [self.rect.x,self.rect.y,self.width,self.height] + return CollisionInfo + +# main entity class +global entity_ID +entity_ID = 0 + +class entity(object): + + def __init__(self,x,y,x_size,y_size): + global entity_ID + self.ID = entity_ID + entity_ID += 1 + self.x = x + self.y = y + self.x_size = x_size + self.y_size = y_size + self.obj = PhysicsObject(self.x,self.y,self.x_size,self.y_size) + + def set_pos(self,x,y): + self.x = x + self.y = y + self.obj.rect.x = x + self.obj.rect.y = y + + def set_size(self,x,y): + self.x_size = x + self.y_size = y + self.obj.rect.width = x + self.obj.rect.height = y + + def move(self,movement,collisions): + collision_feedback = self.obj.Move(movement,collisions) # collisions are a list of objects in [x,y,x_size,y_size] format + self.x = self.obj.x + self.y = self.obj.y + return collision_feedback + + def push(self,movement,collisions,objects): # other objects must be entities + new_list = [] + for collision in collisions: + new_list.append([collision[0],collision[1],collision[2],collision[3],'solid']) + obj_list = [] + for obj in objects: + new_list.append([obj.obj.rect.x,obj.obj.rect.y,obj.obj.rect.width,obj.obj.rect.height,'obj',obj,obj.ID]) + obj_list.append([obj.obj.rect.x,obj.obj.rect.y,obj.obj.rect.width,obj.obj.rect.height,'obj',obj,obj.ID]) + testR = pygame.Rect(self.x+movement[0],self.y+movement[1],self.x_size,self.y_size) + for obj in new_list: + if obj[4] == 'obj': + objR = pygame.Rect(obj[0],obj[1],obj[2],obj[3]) + if testR.colliderect(objR): + dist_x = obj[0]-self.x + if dist_x > 0: + dist_x -= self.x_size + elif dist_x < 0: + dist_x += obj[5].x_size + power_x = movement[0]-dist_x + dist_y = obj[1]-self.y + if dist_y > 0: + dist_y -= self.y_size + elif dist_y < 0: + dist_y += obj[5].y_size + power_y = movement[1]-dist_y + if movement[0] == 0: + power_x = 0 + if movement[1] == 0: + power_y = 0 + spec_list = objects.copy() + for item in spec_list: + if item.ID == obj[6]: + spec_list.remove(item) + obj[5] = obj[5].push([power_x,power_y],collisions,spec_list) + obj[0] = obj[5].rect.x + obj[1] = obj[5].rect.y + self.move(movement,new_list) + return self.obj + + def update_animation(self,anim,key): + anim.move(key,self.x,self.y) + +# animation stuff +global animation_database +animation_database = {} + +# a sequence looks like [[0,1],[1,1],[2,1],[3,1],[4,2]] +# the first numbers are the image name(as integer), while the second number shows the duration of it in the sequence +def animation_sequence(sequence,base_path,colorkey=(255,255,255),transparency=255): + global animation_database + result = [] + for frame in sequence: + image_id = base_path + str(frame[0]) + image = pygame.image.load(image_id + '.png').convert() + image.set_colorkey(colorkey) + image.set_alpha(transparency) + animation_database[image_id] = image.copy() + for i in range(frame[1]): + result.append(image_id) + return result + +def load_sequence(base_path,amount,colorkey=(255,255,255)): + result = [] + for image in range(amount): + img = pygame.image.load(base_path + str(image) + '.png').convert() + img.set_colorkey(colorkey) + result.append(img.copy()) + return result + +# attributes so far are: continuous and loop +# continuous - pauses on last frame in animation +# loop - goes to the beginning after the last frame +# if neither of those are present, then the animation deletes itself +class animation(object): + + def __init__(self,sequence,base_path,attributes=[],colorkey=(255,255,255),transparency=255): + self.sequence = animation_sequence(sequence,base_path,colorkey,transparency) + self.attributes = attributes + self.key_num = 0 + self.active_animations = {} + + def set_attributes(self,attributes): + self.attributes = attributes + + def remove_attributes(self,attributes): + for attribute in attributes: + if attribute in self.attributes: + self.attributes.remove(attribute) + + def add_attributes(self,attributes): + for attribute in attributes: + self.attributes.append(attribute) + + def start(self,x,y): + self.key_num += 1 + self.active_animations[self.key_num] = [x,y,0,None] + return self.key_num # returns a key for the current animation, it's used to handle it + + def play(self,key,surf,flip=False,show=True,offset=[0,0],transparency=255): # play both displays and handles the frame + global animation_database + anim_read = self.active_animations[key] + animation_database[self.sequence[anim_read[2]]].set_alpha(transparency) + if anim_read[3] == None: + if flip == False: + surf.blit(animation_database[self.sequence[anim_read[2]]],(anim_read[0]+offset[0],anim_read[1]+offset[1])) + else: + surf.blit(pygame.transform.flip(animation_database[self.sequence[anim_read[2]]],True,False),(anim_read[0]+offset[0],anim_read[1]+offset[1])) + else: + if flip == False: + surf.blit(anim_read[3],(anim_read[0]+offset[0],anim_read[1]+offset[1])) + else: + surf.blit(pygame.transform.flip(anim_read[3],True,False),(anim_read[0]+offset[0],anim_read[1]+offset[1])) + self.active_animations[key][3] = None + self.active_animations[key][2] += 1 + if self.active_animations[key][2] >= len(self.sequence): + if 'continuous' in self.attributes: + self.active_animations[key][2] -= 1 + elif 'loop' in self.attributes: + self.active_animations[key][2] = 0 + else: + del self.active_animations[key] + return self.active_animations[key][2] + + def reset(self,key): + self.active_animations[key][2] = 0 + + def stop(self,key): + del self.active_animations[key] + + def move(self,key,x,y): + self.active_animations[key][0] = x + self.active_animations[key][1] = y + + # not using .copy() in the function when setting a var to the output will make the var the same as the change + def next_image(self,key,update=None): # can be used to check the next image/change it + self.active_animations[key][3] = update + return animation_database[self.sequence[self.active_animations[key][2]]] + + diff --git a/index.js b/index.js deleted file mode 100644 index 2d7e6834fb6366b3120c7a37cc5f637bc4a33928..0000000000000000000000000000000000000000 --- a/index.js +++ /dev/null @@ -1 +0,0 @@ -console.log("欢迎来到 InsCode"); \ No newline at end of file diff --git a/inscode.nix b/inscode.nix index 12841f8a4f193f44c7c755a8821606a6447a7584..336b12156c32e7122427917df21166813e949a2c 100644 --- a/inscode.nix +++ b/inscode.nix @@ -1,6 +1,6 @@ { pkgs }: { deps = [ - pkgs.nodejs-18_x + pkgs.python-18_x pkgs.yarn ]; } \ No newline at end of file diff --git a/package.json b/package.json index 72caa1750a1c44c18460a496d258fbd3c51c673a..69cc15c3d841084d431b3e12e869123f99ae4a91 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { - "name": "nodejs", + "name": "python", "version": "1.0.0", "description": "", - "main": "index.js", + "main": "index.py", "scripts": { - "dev": "node index.js", + "dev": "node index.py", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], diff --git a/text.py b/text.py new file mode 100644 index 0000000000000000000000000000000000000000..1fa0f9fac4800e49d31add81e341748c21e86adb --- /dev/null +++ b/text.py @@ -0,0 +1,81 @@ +import pygame +from copy import deepcopy + +def show_text(Text,X,Y,Spacing,WidthLimit,Font,surface,double=1,overflow='normal'): + Text += ' ' + OriginalX = X + OriginalY = Y + CurrentWord = '' + if overflow == 'normal': + for char in Text: + if char not in [' ','\n']: + try: + Image = Font[str(char)][1] + CurrentWord += str(char) + except KeyError: + pass + else: + WordTotal = 0 + for char2 in CurrentWord: + WordTotal += Font[char2][0] + WordTotal += Spacing + if WordTotal+X-OriginalX > WidthLimit: + X = OriginalX + Y += Font['Height'] + for char2 in CurrentWord: + Image = Font[str(char2)][1] + surface.blit(pygame.transform.scale(Image,(Image.get_width()*double,Image.get_height()*double)),(X*double,Y*double)) + X += Font[char2][0] + X += Spacing + if char == ' ': + X += Font['A'][0] + X += Spacing + else: + X = OriginalX + Y += Font['Height'] + CurrentWord = '' + if X-OriginalX > WidthLimit: + X = OriginalX + Y += Font['Height'] + return X,Y + if overflow == 'cut all': + for char in Text: + if char not in [' ','\n']: + try: + Image = Font[str(char)][1] + surface.blit(pygame.transform.scale(Image,(Image.get_width()*double,Image.get_height()*double)),(X*double,Y*double)) + X += Font[str(char)][0] + X += Spacing + except KeyError: + pass + else: + if char == ' ': + X += Font['A'][0] + X += Spacing + if char == '\n': + X = OriginalX + Y += Font['Height'] + CurrentWord = '' + if X-OriginalX > WidthLimit: + X = OriginalX + Y += Font['Height'] + return X,Y + +def generate_font(FontImage,FontSpacingMain,TileSize,TileSizeY,color): + FontSpacing = deepcopy(FontSpacingMain) + FontOrder = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','.','-',',',':','+','\'','!','?','0','1','2','3','4','5','6','7','8','9','(',')','/','_','=','\\','[',']','*','"','<','>',';'] + FontImage = pygame.image.load(FontImage).convert() + NewSurf = pygame.Surface((FontImage.get_width(),FontImage.get_height())).convert() + NewSurf.fill(color) + FontImage.set_colorkey((0,0,0)) + NewSurf.blit(FontImage,(0,0)) + FontImage = NewSurf.copy() + FontImage.set_colorkey((255,255,255)) + num = 0 + for char in FontOrder: + FontImage.set_clip(pygame.Rect(((TileSize+1)*num),0,TileSize,TileSizeY)) + CharacterImage = FontImage.subsurface(FontImage.get_clip()) + FontSpacing[char].append(CharacterImage) + num += 1 + FontSpacing['Height'] = TileSizeY + return FontSpacing