Mozaik effekt
This commit is contained in:
@@ -9,13 +9,13 @@ gamestates = {
|
|||||||
}
|
}
|
||||||
gamestate = "none"
|
gamestate = "none"
|
||||||
|
|
||||||
def switch_gamestate(state):
|
def switch_gamestate(game, state):
|
||||||
global gamestate
|
global gamestate
|
||||||
gamestate = state
|
gamestate = state
|
||||||
gamestates[gamestate].switch()
|
gamestates[gamestate].switch(game)
|
||||||
|
|
||||||
def update(dt):
|
def update(game, dt):
|
||||||
gamestates[gamestate].update(dt)
|
gamestates[gamestate].update(game, dt)
|
||||||
|
|
||||||
def draw(game):
|
def draw(game):
|
||||||
gamestates[gamestate].draw(game)
|
gamestates[gamestate].draw(game)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import gamestate
|
import gamestate
|
||||||
|
|
||||||
# Azért létezik ez a "none" gamestate hogy meghívja az elsö gamestate init() funkcióját
|
# Azért létezik ez a "none" gamestate hogy meghívja az elsö gamestate init() funkcióját
|
||||||
def update(dt):
|
def update(game, dt):
|
||||||
gamestate.switch_gamestate("overworld")
|
gamestate.switch_gamestate(game, "title")
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ OVERWORLD_MAP = [
|
|||||||
[0,0,0,0],
|
[0,0,0,0],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BalthasarController:
|
class BalthasarController:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.direction = DIR_UP
|
self.direction = DIR_UP
|
||||||
@@ -95,10 +93,10 @@ class OverworldMap:
|
|||||||
controller = BalthasarController()
|
controller = BalthasarController()
|
||||||
overworld = OverworldMap()
|
overworld = OverworldMap()
|
||||||
|
|
||||||
def switch():
|
def switch(game):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def update(dt):
|
def update(game, dt):
|
||||||
controller.update()
|
controller.update()
|
||||||
|
|
||||||
if controls.is_control_pressed(0): # Fel
|
if controls.is_control_pressed(0): # Fel
|
||||||
|
|||||||
@@ -10,18 +10,24 @@ panel = renderers.NineSlicesPanel(0,100,230,100)
|
|||||||
|
|
||||||
m = []
|
m = []
|
||||||
|
|
||||||
def switch():
|
def mos_1x(g):
|
||||||
|
g.mosaic = 1
|
||||||
|
|
||||||
|
def mos_2x(g):
|
||||||
|
g.mosaic = 2
|
||||||
|
|
||||||
|
def switch(game):
|
||||||
global m
|
global m
|
||||||
m = [
|
m = [
|
||||||
menu.MenuItem("1", 100, 90, None, None, None, None, None, None),
|
menu.MenuItem("1", 100, 90, None, None, None, None, mos_1x, game),
|
||||||
menu.MenuItem("2", 100, 70 , None, None, None, None, None, None)
|
menu.MenuItem("2", 100, 70 , None, None, None, None, mos_2x, game)
|
||||||
]
|
]
|
||||||
|
|
||||||
m[0].down = m[1]
|
m[0].down = m[1]
|
||||||
m[1].up = m[0]
|
m[1].up = m[0]
|
||||||
m[0].select()
|
m[0].select()
|
||||||
|
|
||||||
def update(dt):
|
def update(game, dt):
|
||||||
controltext = ""
|
controltext = ""
|
||||||
|
|
||||||
for c in controls.controls:
|
for c in controls.controls:
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ class Game(arcade.Window):
|
|||||||
|
|
||||||
self.screen_width = SCREEN_WIDTH
|
self.screen_width = SCREEN_WIDTH
|
||||||
self.screen_height = SCREEN_HEIGHT
|
self.screen_height = SCREEN_HEIGHT
|
||||||
|
self.mosaic = 1
|
||||||
|
self.mos_enabled = False
|
||||||
|
|
||||||
self.game_texture = self.ctx.texture(
|
self.game_texture = self.ctx.texture(
|
||||||
(SCREEN_WIDTH, SCREEN_HEIGHT),
|
(SCREEN_WIDTH, SCREEN_HEIGHT),
|
||||||
@@ -33,7 +35,7 @@ class Game(arcade.Window):
|
|||||||
self.renderer = renderers.TextureRenderer(self.ctx)
|
self.renderer = renderers.TextureRenderer(self.ctx)
|
||||||
|
|
||||||
def on_update(self, dt):
|
def on_update(self, dt):
|
||||||
gamestate.update(dt)
|
gamestate.update(game, dt)
|
||||||
controls.update()
|
controls.update()
|
||||||
|
|
||||||
def on_key_press(self, symbol, modifiers):
|
def on_key_press(self, symbol, modifiers):
|
||||||
@@ -73,6 +75,8 @@ class Game(arcade.Window):
|
|||||||
y,
|
y,
|
||||||
scaled_width,
|
scaled_width,
|
||||||
scaled_height,
|
scaled_height,
|
||||||
|
self.mosaic,
|
||||||
|
self.mos_enabled
|
||||||
)
|
)
|
||||||
|
|
||||||
game = Game()
|
game = Game()
|
||||||
|
|||||||
@@ -34,24 +34,36 @@ class TextureRenderer:
|
|||||||
""",
|
""",
|
||||||
fragment_shader="""
|
fragment_shader="""
|
||||||
#version 330
|
#version 330
|
||||||
|
#define INV_RESOLUTION_X (1. / screen_size.x)
|
||||||
|
#define INV_RESOLUTION_Y (1. / screen_size.y)
|
||||||
|
|
||||||
|
uniform vec2 screen_size;
|
||||||
uniform sampler2D tex;
|
uniform sampler2D tex;
|
||||||
|
uniform float mosaic;
|
||||||
|
uniform bool mos_enabled;
|
||||||
|
|
||||||
in vec2 uv;
|
in vec2 uv;
|
||||||
out vec4 color;
|
out vec4 color;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
color = texture(tex, uv);
|
vec2 new_uv = vec2(
|
||||||
|
(floor((uv.x / INV_RESOLUTION_X) / mosaic) * INV_RESOLUTION_X) * mosaic,
|
||||||
|
(floor((uv.y / INV_RESOLUTION_Y) / mosaic) * INV_RESOLUTION_Y) * mosaic
|
||||||
|
);
|
||||||
|
|
||||||
|
color = texture(tex, mos_enabled ? new_uv : uv);
|
||||||
}
|
}
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.quad = arcade.gl.geometry.quad_2d_fs()
|
self.quad = arcade.gl.geometry.quad_2d_fs()
|
||||||
|
|
||||||
def render(self, texture, x, y, width, height):
|
def render(self, texture, x, y, width, height, mosaic, mos_enabled):
|
||||||
self.program["screen_size"] = (self.ctx.screen.width,
|
self.program["screen_size"] = (self.ctx.screen.width,
|
||||||
self.ctx.screen.height)
|
self.ctx.screen.height)
|
||||||
self.program["bounds"] = (x, y, width, height)
|
self.program["bounds"] = (x, y, width, height)
|
||||||
|
self.program["mosaic"] = mosaic
|
||||||
|
self.program["mos_enabled"] = mos_enabled
|
||||||
|
|
||||||
texture.use(0)
|
texture.use(0)
|
||||||
self.program["tex"] = 0
|
self.program["tex"] = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user