-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initiated pygame and created the main screen
- Loading branch information
Showing
4 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pygame, sys | ||
from settings import * | ||
class Game: | ||
def __init__(self): | ||
pygame.init() | ||
self.screen=pygame.display.set_mode((SCREEN_WIDTH,SCREEN_HEIGHT)) | ||
pygame.display.set_caption('New_Game') | ||
self.clock=pygame.time.Clock() | ||
|
||
def run(self): | ||
while True: | ||
for event in pygame.event.get(): | ||
if event.type== pygame.QUIT: | ||
pygame.quit() | ||
sys.exit() | ||
dt= self.clock.tick()/1000 | ||
pygame.display.update() | ||
if __name__=='__main__': | ||
game=Game() | ||
game.run() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from pygame.math import Vector2 | ||
# screen | ||
SCREEN_WIDTH = 1280 | ||
SCREEN_HEIGHT = 720 | ||
TILE_SIZE = 64 | ||
|
||
# overlay positions | ||
OVERLAY_POSITIONS = { | ||
'tool' : (40, SCREEN_HEIGHT - 15), | ||
'seed': (70, SCREEN_HEIGHT - 5)} | ||
|
||
PLAYER_TOOL_OFFSET = { | ||
'left': Vector2(-50,40), | ||
'right': Vector2(50,40), | ||
'up': Vector2(0,-10), | ||
'down': Vector2(0,50) | ||
} | ||
|
||
LAYERS = { | ||
'water': 0, | ||
'ground': 1, | ||
'soil': 2, | ||
'soil water': 3, | ||
'rain floor': 4, | ||
'house bottom': 5, | ||
'ground plant': 6, | ||
'main': 7, | ||
'house top': 8, | ||
'fruit': 9, | ||
'rain drops': 10 | ||
} | ||
|
||
APPLE_POS = { | ||
'Small': [(18,17), (30,37), (12,50), (30,45), (20,30), (30,10)], | ||
'Large': [(30,24), (60,65), (50,50), (16,40),(45,50), (42,70)] | ||
} | ||
|
||
GROW_SPEED = { | ||
'corn': 1, | ||
'tomato': 0.7 | ||
} | ||
|
||
SALE_PRICES = { | ||
'wood': 4, | ||
'apple': 2, | ||
'corn': 10, | ||
'tomato': 20 | ||
} | ||
PURCHASE_PRICES = { | ||
'corn': 4, | ||
'tomato': 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
class Node: | ||
def __init__(self, data): | ||
self.left = None | ||
self.right = None | ||
self.data = data | ||
# Insert method to create nodes | ||
def insert(self, data): | ||
if self.data: | ||
if data < self.data: | ||
if self.left is None: | ||
self.left = Node(data) | ||
else: | ||
self.left.insert(data) | ||
elif data > self.data: | ||
if self.right is None: | ||
self.right = Node(data) | ||
else: | ||
self.right.insert(data) | ||
else: | ||
self.data = data | ||
# findval method to compare the value with nodes | ||
def deletion(self,lkpval): | ||
if lkpval < self.data: | ||
if self.left is None: | ||
return str(lkpval)+" Not Found" | ||
return self.left.deletion(lkpval) | ||
elif lkpval > self.data: | ||
if self.right is None: | ||
return str(lkpval)+" Not Found" | ||
return self.right.deletion(lkpval) | ||
else: | ||
if self.left is None and self.right is not None: | ||
self.data=self.right.data | ||
self.right.data=None | ||
return | ||
elif self.left is not None: | ||
self.data=self.left.data | ||
self.left.data=None | ||
return | ||
else: | ||
self.data=None | ||
return | ||
# Print the tree | ||
def PrintTree(self): | ||
if self.data is not None: | ||
if self.left: | ||
self.left.PrintTree() | ||
print( self.data) | ||
if self.right: | ||
self.right.PrintTree() | ||
root = Node(12) | ||
root.insert(6) | ||
root.insert(14) | ||
root.insert(3) | ||
print(root.deletion(12)) | ||
root.PrintTree() |