diff --git a/src/.DS_Store b/src/.DS_Store index d0ab1934098e6cfd1743bed893a60f2bdc8a3238..af9d3ebe10f948bd00133c01b476457d34aa42aa 100755 Binary files a/src/.DS_Store and b/src/.DS_Store differ diff --git a/src/__pycache__/algorithms.cpython-37.pyc b/src/__pycache__/algorithms.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2c31d8f57d40af974a4eecd9baad0df29e272062 Binary files /dev/null and b/src/__pycache__/algorithms.cpython-37.pyc differ diff --git a/src/__pycache__/game.cpython-37.pyc b/src/__pycache__/game.cpython-37.pyc index b6f8a5511f12e0adbdb941ee0e97963df47a9745..36a0a01a8bcd3b94510fe282724ad1092e0631c0 100644 Binary files a/src/__pycache__/game.cpython-37.pyc and b/src/__pycache__/game.cpython-37.pyc differ diff --git a/src/__pycache__/load.cpython-37.pyc b/src/__pycache__/load.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9d7e2554077144c7559c97dfdceb2397c6aef236 Binary files /dev/null and b/src/__pycache__/load.cpython-37.pyc differ diff --git a/src/__pycache__/view.cpython-37.pyc b/src/__pycache__/view.cpython-37.pyc index bd4fe5ac6eee6eecf188357f2dfb77442d3f0828..5b3ae743d05c563c82b9add829fb25b2c5ee6db9 100644 Binary files a/src/__pycache__/view.cpython-37.pyc and b/src/__pycache__/view.cpython-37.pyc differ diff --git a/src/__pycache__/world.cpython-37.pyc b/src/__pycache__/world.cpython-37.pyc index 64554f0e4920f87b101ce499e30ca544c08d14f7..e179e3b99f50aaf95faabd97c24e8897249063fa 100644 Binary files a/src/__pycache__/world.cpython-37.pyc and b/src/__pycache__/world.cpython-37.pyc differ diff --git a/src/mathModel.py b/src/algorithms.py similarity index 96% rename from src/mathModel.py rename to src/algorithms.py index 6d78ff000f06015f64cad16650c2937b7cc3bc18..965679ab047cfac1eae4b47c9705d7f88d3c8c39 100755 --- a/src/mathModel.py +++ b/src/algorithms.py @@ -1,4 +1,6 @@ SECTOR_SIZE = 16 + + def normalize(position): """ Accepts `position` of arbitrary precision and returns the block containing that position. diff --git a/src/game.py b/src/game.py index f67281f70c98a81cff29f80b736044f34529ba52..837d4d4ee17633caa604018dfe74a65e3e575426 100755 --- a/src/game.py +++ b/src/game.py @@ -1,21 +1,29 @@ from __future__ import division - -import time from block import Block from view import View from world import World -from mathModel import * +from algorithms import * +from collections import deque +from pyglet import image +from pyglet.gl import * +from pyglet.graphics import TextureGroup +from pyglet.window import key, mouse + +import load +import time import os import sys import math import random import time -from collections import deque -from pyglet import image -from pyglet.gl import * -from pyglet.graphics import TextureGroup -from pyglet.window import key, mouse +#Version Controls +if sys.version_info[0] >= 3: + xrange = range + if sys.version_info[0] * 10 + sys.version_info[1] >= 38: + time.clock = time.process_time + + TICKS_PER_SEC = 60 @@ -38,17 +46,17 @@ JUMP_SPEED = math.sqrt(2 * GRAVITY * MAX_JUMP_HEIGHT) TERMINAL_VELOCITY = 50 PLAYER_HEIGHT = 2 -if sys.version_info[0] >= 3: - xrange = range - if sys.version_info[0] * 10 + sys.version_info[1] >= 38: - time.clock = time.process_time +class Game(pyglet.window.Window): + + #Blocks intialization + + global BRICK, GRASS, STONE, MARBO + BRICK = load.BRICK + GRASS = load.GRASS + STONE = load.STONE + MARBO = load.MARBO -BRICK = Block((0, 0), (0, 0), (0, 0), 1, os.path.join("texture","Brick.png")) -GRASS = Block((0, 0), (0, 1), (1, 1), 2, os.path.join("texture","Grass.png")) -STONE = Block((0, 0), (0, 0), (0, 0), 1,os.path.join("texture","Stone.png")) -MARBO = Block((0, 0), (0, 0), (0, 0), 1,os.path.join("texture","Marbo.png")) -class Game(pyglet.window.Window): def __init__(self, *args, **kwargs): super(Game, self).__init__(*args, **kwargs) # Whether or not the window exclusively captures the mouse. diff --git a/src/load.py b/src/load.py new file mode 100644 index 0000000000000000000000000000000000000000..47dd6cffd4a27953b8d9151d6381b0db73366847 --- /dev/null +++ b/src/load.py @@ -0,0 +1,13 @@ +import os + +from block import Block +from pyglet.gl import * + +ICON = pyglet.image.load(os.path.join("media","icon.png")) +BUILDSOUND = pyglet.resource.media(os.path.join("media","build.wav"),streaming=False) +DESTROYSOUND = pyglet.resource.media(os.path.join("media",'destroy.wav'),streaming=False) +BACKGROUNDMUSIC = pyglet.resource.media(os.path.join("media",'bgmusic.wav')) +BRICK = Block((0, 0), (0, 0), (0, 0), 1, os.path.join("texture","Brick.png")) +GRASS = Block((0, 0), (0, 1), (1, 1), 2, os.path.join("texture","Grass.png")) +STONE = Block((0, 0), (0, 0), (0, 0), 1, os.path.join("texture","Stone.png")) +MARBO = Block((0, 0), (0, 0), (0, 0), 1, os.path.join("texture","Marbo.png")) diff --git a/src/main.py b/src/main.py index e0e33a458226f646f64cd005cb46958a6aed8c60..4ddbb2660307beedd517a450eb54919fd03ff6c6 100755 --- a/src/main.py +++ b/src/main.py @@ -1,6 +1,7 @@ +import os +import load from pyglet.gl import * - from view import View from game import Game @@ -8,15 +9,16 @@ WINDOW_WIDTH = 800 WINDOW_HEIGHT = 600 def main(): - game = Game(width=WINDOW_WIDTH, height=WINDOW_HEIGHT, caption='MineCraft', resizable=True) - icon = pyglet.image.load("icon.png") - game.buildSound = pyglet.resource.media('build.wav',streaming=False) - game.destroySound = pyglet.resource.media('destroy.wav',streaming=False) - game.backgroundSound = pyglet.resource.media('bgmusic.wav') - game.set_icon(icon) + + + game = Game(width=WINDOW_WIDTH, height=WINDOW_HEIGHT, caption='CraftMaster', resizable=True) + game.buildSound = load.BUILDSOUND + game.destroySound = load.DESTROYSOUND + game.backgroundMusic = load.BACKGROUNDMUSIC + game.set_icon(load.ICON) # Hide the mouse cursor and prevent the mouse from leaving the window. game.set_exclusive_mouse(True) - game.backgroundSound.play() + game.backgroundMusic.play() pyglet.app.run() diff --git a/src/media/.DS_Store b/src/media/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..73111e2b499d73306f523e893afa548e86dd9a75 Binary files /dev/null and b/src/media/.DS_Store differ diff --git a/src/bgmusic.wav b/src/media/bgmusic.wav similarity index 100% rename from src/bgmusic.wav rename to src/media/bgmusic.wav diff --git a/src/build.wav b/src/media/build.wav similarity index 100% rename from src/build.wav rename to src/media/build.wav diff --git a/src/destroy.wav b/src/media/destroy.wav similarity index 100% rename from src/destroy.wav rename to src/media/destroy.wav diff --git a/src/icon.png b/src/media/icon.png similarity index 100% rename from src/icon.png rename to src/media/icon.png diff --git a/src/view.py b/src/view.py index dccc57eaced39416ad6f4835afaa8b21414f41ba..48829c4f96616bc8ca74bf275cf03a4e39eb73c7 100755 --- a/src/view.py +++ b/src/view.py @@ -1,4 +1,4 @@ -from mathModel import * +from algorithms import * import sys import math diff --git a/src/world.py b/src/world.py index 17a6de873d343de972ae4df875c818946f6c9251..5e718e35b7b8ccc37edcb32649be55a6894b56e6 100755 --- a/src/world.py +++ b/src/world.py @@ -1,19 +1,22 @@ -from mathModel import * - import sys import math import random import time +from algorithms import * from collections import deque from pyglet import image from pyglet.gl import * from pyglet.graphics import TextureGroup from pyglet.window import key, mouse + +#Version Controls if sys.version_info[0] >= 3: xrange = range if sys.version_info[0] * 10 + sys.version_info[1] >= 38: time.clock = time.process_time + + TICKS_PER_SEC = 60 # Size of sectors used to ease block loading.