Cloud Based Gaming Platform
Cloud Based Gaming Platform
ABSTRACT:
The emergence of blockchain technology has paved the way for decentralized
applications (D Apps) that offer innovative solutions in various domains. In the
gaming industry, Oracle-based platforms are gaining attention for their ability to
securely integrate real-world data into smart contracts, enhancing the transparency
and reliability of gameplay.
This paper explores the design and implementation of an Oracle- based
gaming platform that leverages decentralized oracles to fetch external data for
gameplay mechanics. The platform utilizes blockchain technology, specifically
smart contracts, to execute game logic in a transparent and tamper-proof
manner. By integrating oracles, the platform can access off chain data, such as
sports scores, weather conditions, or random number generation, ensuring
fairness and accuracy in gameplay outcomes.
2. SOFTWARE SYSTEM:
-- Networking
-- Backup software
-- Scalability
TOOLS AND VERSIONS:
import pygame
from pygame.locals import *
FPS = 30
SCREENWIDTH = 288
SCREENHEIGHT = 512
PIPEGAPSIZE = 100 # gap between upper and lower part of pipe
BASEY = SCREENHEIGHT * 0.79
# image, sound and hitmask dicts
IMAGES, SOUNDS, HITMASKS = {}, {}, {}
# list of backgrounds
BACKGROUNDS_LIST = (
'assets/sprites/background-day.png',
'assets/sprites/background-night.png',
)
# list of pipes
PIPES_LIST = (
'assets/sprites/pipe-green.png',
'assets/sprites/pipe-red.png',
)
try:
xrange
except NameError:
xrange = range
def main():
global SCREEN, FPSCLOCK
pygame.init()
FPSCLOCK = pygame.time.Clock()
# Fullscreen scaled output
SCREEN = pygame.display.set_mode((SCREENWIDTH, SCREENHEIGHT),
pygame.SCALED | pygame.FULLSCREEN)
pygame.display.set_caption('Flappy Box')
# sounds
soundExt = '.ogg'
SOUNDS['die'] = pygame.mixer.Sound('assets/audio/die' + soundExt)
SOUNDS['hit'] = pygame.mixer.Sound('assets/audio/hit' + soundExt)
SOUNDS['point'] = pygame.mixer.Sound('assets/audio/point' + soundExt)
SOUNDS['wing'] = pygame.mixer.Sound('assets/audio/wing' + soundExt)
while True:
# select random background sprites
randBg = random.randint(0, len(BACKGROUNDS_LIST) - 1)
IMAGES['background'] =
pygame.image.load(BACKGROUNDS_LIST[randBg]).convert()
pygame.transform.flip(pygame.image.load(PIPES_LIST[pipeindex]).convert_alpha(),
False, True),
pygame.image.load(PIPES_LIST[pipeindex]).convert_alpha(),
)
movementInfo = showWelcomeAnimation()
crashInfo = mainGame(movementInfo)
showGameOverScreen(crashInfo)
def showWelcomeAnimation():
"""Shows welcome screen animation of flappy box"""
# index of player to blit on screen
playerIndex = 0
playerIndexGen = cycle([0, 1, 2, 1])
# iterator used to change playerIndex after every 5th iteration
loopIter = 0
while True:
for event in pygame.event.get():
if event.type == QUIT or (event.type == KEYDOWN and event.key ==
K_ESCAPE):
pygame.quit()
sys.exit()
if event.type == KEYDOWN and (event.key == K_SPACE or event.key ==
K_UP) or event.type == MOUSEBUTTONDOWN:
# make first flap sound and return values for mainGame
SOUNDS['wing'].play()
return {
'playery': playery + playerShmVals['val'],
'basex': basex,
'playerIndexGen': playerIndexGen,
}
pygame.display.update()
FPSCLOCK.tick(FPS)
def mainGame(movementInfo):
score = playerIndex = loopIter = 0
playerIndexGen = movementInfo['playerIndexGen']
playerx, playery = int(SCREENWIDTH * 0.2), movementInfo['playery']
basex = movementInfo['basex']
baseShift = IMAGES['base'].get_width() - IMAGES['background'].get_width()
# list of lowerpipe
lowerPipes = [
{
'x': SCREENWIDTH + 200,
'y': newPipe1[1]['y']
},
{
'x': SCREENWIDTH + 200 + (SCREENWIDTH / 2),
'y': newPipe2[1]['y']
},
]
pipeVelX = -4
# player's movement
if playerVelY < playerMaxVelY and not playerFlapped:
playerVelY += playerAccY
if playerFlapped:
playerFlapped = False
playerHeight = IMAGES['player'][playerIndex].get_height()
playery += min(playerVelY, BASEY - playery - playerHeight)
# add new pipe when first pipe is about to touch left of screen
if len(upperPipes) > 0 and 0 < upperPipes[0]['x'] < 5:
newPipe = getRandomPipe()
upperPipes.append(newPipe[0])
lowerPipes.append(newPipe[1])
# draw sprites
SCREEN.blit(IMAGES['background'], (0, 0))
playerSurface = pygame.transform.rotate(IMAGES['player'][playerIndex],
visibleRot)
SCREEN.blit(playerSurface, (playerx, playery))
pygame.display.update()
FPSCLOCK.tick(FPS)
def showGameOverScreen(crashInfo):
"""crashes the player down ans shows gameover image"""
score = crashInfo['score']
playerx = SCREENWIDTH * 0.2
playery = crashInfo['y']
playerHeight = IMAGES['player'][0].get_height()
playerVelY = crashInfo['playerVelY']
playerAccY = 2
playerRot = crashInfo['playerRot']
playerVelRot = 7
basex = crashInfo['basex']
while True:
for event in pygame.event.get():
if event.type == QUIT or (event.type == KEYDOWN and event.key ==
K_ESCAPE):
pygame.quit()
sys.exit()
if event.type == KEYDOWN and (event.key == K_SPACE or event.key ==
K_UP) or event.type == MOUSEBUTTONDOWN:
if playery + playerHeight >= BASEY - 1:
return
# player y shift
if playery + playerHeight < BASEY - 1:
playery += min(playerVelY, BASEY - playery - playerHeight)
# draw sprites
SCREEN.blit(IMAGES['background'], (0, 0))
FPSCLOCK.tick(FPS)
pygame.display.update()
def playerShm(playerShm):
"""oscillates the value of playerShm['val'] between 8 and -8"""
if abs(playerShm['val']) == 8:
playerShm['dir'] *= -1
if playerShm['dir'] == 1:
playerShm['val'] += 1
else:
playerShm['val'] -= 1
def getRandomPipe():
"""returns a randomly generated pipe"""
# y of gap between upper and lower pipe
gapY = random.randrange(0, int(BASEY * 0.6 - PIPEGAPSIZE))
gapY += int(BASEY * 0.2)
pipeHeight = IMAGES['pipe'][0].get_height()
pipeX = SCREENWIDTH + 10
return [
{
'x': pipeX,
'y': gapY - pipeHeight
}, # upper pipe
{
'x': pipeX,
'y': gapY + PIPEGAPSIZE
}, # lower pipe
]
def showScore(score):
"""displays score in center of screen"""
scoreDigits = [int(x) for x in list(str(score))]
totalWidth = 0 # total width of all numbers to be printed
if uCollide or lCollide:
return [True, False]
if rect.width == 0 or rect.height == 0:
return False
x1, y1 = rect.x - rect1.x, rect.y - rect1.y
x2, y2 = rect.x - rect2.x, rect.y - rect2.y
for x in xrange(rect.width):
for y in xrange(rect.height):
if hitmask1[x1 + x][y1 + y] and hitmask2[x2 + x][y2 + y]:
return True
return False
def getHitmask(image):
"""returns a hitmask using an image's alpha."""
mask = []
for x in xrange(image.get_width()):
mask.append([])
for y in xrange(image.get_height()):
mask[x].append(bool(image.get_at((x, y))[3]))
return mask
if _name_ == '_main_':
main()
OUTPUT:
PROJECT HURDLES:
Oracle-based gaming platforms often face hurdles such as high
implementation costs, complexity in integrating blockchain technology,
scalability issues, and ensuring security and data privacy. Additionally, there
may be challenges with regulatory compliance, maintaining user trust, and
developing a seamless user experience. Technical expertise
is crucial, making it difficult to find and retain skilled developers.
FUTURE SCOPE:
CONCLUSION: