def create_room(): # 생성 요청 global game_data room_number = TcpContoller.send_create_room(game_data.client_socket, game_data.player_number, "TEST_ROOM", 3, "Witch") if room_number != -1: C_Game_framework.push_state(C_CharSellect_State) else: pass
def handle_events(frame_time): global _WAND events = get_events() for event in events: if event.type == SDL_QUIT: C_Game_framework.quit() else: if (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): C_Game_framework.quit() elif (event.type) == (SDL_MOUSEBUTTONDOWN): if _WAND.x > 400: if _WAND.x < 580: if _WAND.y > 270: if _WAND.y < 405: C_Game_framework.push_state(C_collision) if _WAND.x > 600: if _WAND.x < 780: if _WAND.y > 270: if _WAND.y < 405: C_Game_framework.push_state(C_Lobby_state) if _WAND.x > 800: if _WAND.x < 980: if _WAND.y > 270: if _WAND.y < 405: C_Game_framework.quit() else: _WAND.handle_event(event)
def update(frame_time): global name global logo_time if (logo_time > 1): logo_time = 0 C_Game_framework.change_state(C_title_state) #game_framework.quit() logo_time += frame_time
def join_room(): # 참가 요청 if selection > len(rooms_data) or selection < 0 : return result = TcpContoller.send_join_room(game_data.client_socket, rooms_data[selection-1]['room_number'], "Witch2") if result == 1: C_Game_framework.push_state(C_CharSellect_State) elif result == 2: print('is full') elif result == 3: print('is started')
def join_room(): global room_image_state, image_time if selection > len(rooms_data) or selection < 0 : return result = TcpContoller.send_join_room(game_data.client_socket, rooms_data[selection-1]['room_number'], "Witch2") if result == CAN_JOIN: C_Game_framework.push_state(C_CharSellect_State) elif result == ROOM_IS_FULL: room_image_state = ROOM_IS_FULL image_time = 0 elif result == GAME_IS_STARTED: room_image_state = GAME_IS_STARTED image_time = 0
def handle_events(frame_time): events = get_events() for event in events: if event.type == SDL_QUIT: C_Game_framework.quit() else: if (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): C_Game_framework.quit() elif event.type == SDL_MOUSEBUTTONDOWN: for i in range(0, 8): if collide_point((_WAND.x, _WAND.y), COLLISION_BOX[i]): handle_function[i]() break else: _WAND.handle_event(event)
def handle_events(frame_time): global select_witch, readyState, _WAND events = get_events() for event in events: if event.type == SDL_QUIT: State.C_Game_framework.quit() else: if (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): State.C_Game_framework.quit() elif (event.type) == (SDL_MOUSEBUTTONDOWN): if _WAND.x > 30 : if _WAND.x < 275: if _WAND.y > 40: if _WAND.y < 350: select_witch= 1 if _WAND.x > 305: if _WAND.x < 545: if _WAND.y > 40: if _WAND.y < 350: select_witch =2 if _WAND.x > 580: if _WAND.x < 820: if _WAND.y > 40: if _WAND.y < 350: select_witch=3 #READY! if _WAND.x > 905 : if _WAND.x < 1115: if _WAND.y > 230: if _WAND.y < 330: readyState= 1 if select_witch != 0 : C_Game_framework.run(C_collision) State.C_Game_framework.run(C_collision) #EXIT if _WAND.x > 905 : if _WAND.x < 1115: if _WAND.y > 90: if _WAND.y < 190: C_Game_framework.run(C_title_state) State.C_Game_framework.run(C_title_state) else: _WAND.handle_event(event)
def update(frame_time): global _WAND, GAME_STATE, select_witch, readystate, exit_state, delta_time, game_data _WAND.update(frame_time) delta_time += frame_time if delta_time >= 0.3: TcpContoller.send_in_room_data(game_data.client_socket, select_witch, readystate, exit_state) room_data = TcpContoller.receive_in_room_data(game_data.client_socket) game_data.waitting_room_data = room_data delta_time = 0 #if GAME_STATE ==1: ready_count = 0 for i in range(3): if game_data.waitting_room_data['player_ready_state'][i]: ready_count += 1 if ready_count == game_data.waitting_room_data['player_count']: C_Game_framework.push_state(C_collision)
def update(frame_time): global _WAND, GAME_STATE, select_witch , readystate, exit_state, delta_time, \ game_data, emotion_selected, emotion_time, select_imotion exit_ack = False _WAND.update(frame_time) delta_time += frame_time if delta_time >= 0.3: TcpContoller.send_in_room_data(game_data.client_socket, select_witch, readystate, exit_state, select_imotion) select_imotion = 0 if exit_state: exit_ack = TcpContoller.recv_exit_ack(game_data.client_socket) if exit_ack: game_data.waitting_room_data = None C_Game_framework.pop_state() return else: room_data = TcpContoller.receive_in_room_data( game_data.client_socket) game_data.waitting_room_data = room_data delta_time = 0 for i in range(0, 3): if game_data.waitting_room_data['emotion'][i] != 0: emotion_selected[i] = game_data.waitting_room_data['emotion'][i] emotion_time[i] = 0 ready_count = 0 for i in range(3): if game_data.waitting_room_data['player_ready_state'][i]: ready_count += 1 emotion_time[i] += frame_time if ready_count == game_data.waitting_room_data['player_count']: C_Game_framework.run(C_collision)
def start(): pico2d.open_canvas(1200,900,True) C_Game_framework.run(C_title_state) pico2d.close_canvas()
def exit_lobby(): send_exit_server = TcpContoller.send_exit_server(game_data.client_socket) if send_exit_server: TcpContoller.exit(game_data.client_socket) C_Game_framework.pop_state()
def exit_lobby(): C_Game_framework.pop_state()
import os import platform from State import C_Game_framework from State import C_start_state import pico2d # pico2d.open_canvas(1200, 900) C_Game_framework.run(C_start_state) pico2d.close_canvas()