Вы находитесь на странице: 1из 14

A Mini Project Report

on

Rat in a Maze
By
P.HONEY - 1602-14-733-075
Y.BHAVANI-1602-14-733-067

Department of Computer Science & Engineering


Vasavi College of Engineering
(Autonomous)
Ibrahimbagh, Hyderabad-31
2016

ACKNOWLEDGEMENT

We are grateful to our beloved principal Mr. K. Jaya Sankar,M.Tech,Ph.D , for his immense
support in our project work for providing necessary resources in campus. we grateful to
Dr.T.Adilakshmi, M.Tech,Ph.D Head of the Computer Engineering Department us to work
on this project and allowing us use laboratory facilities in the department .We are highly
thankful to other staff members for their valuable guidance and suggestions during our project
work. We wish to express our sincere gratitude to our guide Mr.M.S.V.Sashi Kumar, M. tech,
Department of Computer Engineering for his stimulating guidance during the period of
this project work . we also thank him for his timely guidance and also for the encouragement
showed on us , for the punctual completion of this project. Finally we like to express our
sincere thanks to teaching and non-teaching staff who extended their help when ever needed.

Table of Contents

1 INTRODUCTION:...............................................................................................1
1.1 Purpose:..........................................................................................................1
1.2

Scope:..........................................................................................................1

1.3

Definitions, Acronyms, and Abbreviations:................................................1

1.4 Overview:.....................................................................................................2
2.0

OVERALL DESCRIPTION...........................................................................2

2.1 Product Perspective:......................................................................................3


2.2 Product Functions....................................................................3
2.3

User Characteristics...................................................................................... 3

2.4 General Constraints...................................................................3


3 SPECIFIC REQUIREMENTS.............................................................................3
3.1Functional Requirements..............................................................3
4 CODE.................................................................................................................3-6
5 SCREENSHOTS...................................................................................................6
6 CONCLUSION......................................................................................................................6
7 REFERENCES........................................................................................................................7

ABSTRACT

The rat in a maze game is designed to provide some kind of entertainment to the user by its look
and by playing this game ,user can increase his thinking capacity. It will allow users to enter their
name and compare his score with all other users in the database.It will also give extra benefits
who got more score. The rat in a maze game is designed to provide some kind of entertainment
to the user by its look and by playing this game ,user can increase his thinking capacity.

HARDWARE REQIREMENTS:

Operating system:-windows 8.1

RAM:- 4 GB

Internal memory:-500 GB

Processor:- Intel i3

SOFTWARE REQUIREMENTS:

Software:-Pycharm professional 2016

1.Introduction
1.1 Purpose
The Rat in a Maze is a python application in which rat will move according to the users
input such that rat should find the path from starting block to cheese block in any number of
moves. The maze consists of a large platform with a series of vertical walls and a transparent
ceiling.In t these mazes some are blocked,means rat cannot enter into those cells.
1.2 Scope
The purpose of this specification is to document requirements for a system to manage the Rat in
a Maze python application. The specification identifies what such a system is required to do. In
this game,the user will move the rat in order to reach cheese block by using arrow buttons. In this
,users are provided with daily,weekly challenges whoever wins will be displayed to all other
users as winner.The user can move the rat in any directions(right,left,forward,backward).
1.3 Definitions, Acronyms, and Abbreviations
RIM Rat In Maze
GUI Graphical User Interface

1.4 References
1. S.R.Bharamagoudar1, Geeta R.B.2,
S.G.Totad3 Assistant Professor, Dept. of
Electronics & Communication Engg, Basaveshwar Engg. College, Bagalkot, Karnataka.

1.5 Overview
This specification includes a brief product perspective and a summary of the functions the
software will provide. User characteristics are discussed and any general constraints or
assumptions and dependencies are listed. Requirement statements are categorized as
functional requirements, performance requirements, non-functional requirements, or design
constraints. Functional requirements are further categorized in terms of admin management,
user management. Nonfunctional requirements are further categorized in terms of security,
maintainability, and scalability.
1

2. General Description
2.1 Product Perspective

The rat in a maze game is designed to provide some kind of entertainment to the user by its look
and by playing this game ,user can increase his thinking capacity.

2.2 Product Functions

It will allow users to enter their name and compare his score with all other users in the
database.It will also give extra benefits who got more score.

2.3 User Characteristics

In Rat in a maze ,two types of users are involved:


Type 1:User,who will play the game and get rewarded.
Type2: Admin,who will update user details and update their scores time to time and he only
make new changes into the system.

2.4 General Constraints

The following constraints will limit the developer's options for designing the system:

the budget for this project is less.


implementation is required in 4-6 weeks.

3. Specific Requirements

3.1Functional Requirements
R l. user credentials

R1.1 The user is allowed to enter his personal details like name,phone number.
R1.1.1 The details of user are not necessary.He may provide his details or may not.
R1.2 The users who are participated in this game will be displayed in rank board for every
attempt.
R1.3 The users can see other users score in this game.
R1.4 The users can be provided with gifts when they will be the top ranker.
R1.5

Every user can play this game any number of times .

R1.6 Every user must be provided with a unique id number.

R2. Admin Credentials


R2.1 The admin will be given all the users details and their scores.He will manage them.
R2.2 The admin will be asked to provide his personal details and given a unique id.
R2.3 The admin will contact the users for any updations and changes.
R2.4 The admin will allow to update the user database for every 30 seconds.
R2.5 This game will totally managed by this admin only.

4 Source Code:
#! /usr/bin/env python

import os
import random
import pygame

# Class for the orange dude


class Player(object):
def __init__(self):
self.rect = pygame.Rect(16, 16, 16, 16)
def move(self, dx, dy):

# Move each axis separately. Note that this checks for collisions both times.
if dx != 0:
self.move_single_axis(dx, 0)
if dy != 0:
self.move_single_axis(0, dy)

def move_single_axis(self, dx, dy):

# Move the rect


self.rect.x += dx
self.rect.y += dy
4
# If you collide with a wall, move out based on velocity
for wall in walls:

if self.rect.colliderect(wall.rect):
if dx > 0: # Moving right; Hit the left side of the wall
self.rect.right = wall.rect.left
if dx < 0: # Moving left; Hit the right side of the wall
self.rect.left = wall.rect.right
if dy > 0: # Moving down; Hit the top side of the wall
self.rect.bottom = wall.rect.top
if dy < 0: # Moving up; Hit the bottom side of the wall
self.rect.top = wall.rect.bottom

# Nice class to hold a wall rect


class Wall(object):
def __init__(self, pos):
walls.append(self)
self.rect = pygame.Rect(pos[0], pos[1], 16, 16)

# Initialise pygame
os.environ["SDL_VIDEO_CENTERED"] = "1"
pygame.init()

# Set up the display


pygame.display.set_caption("Move rat to the red cheese!")
screen = pygame.display.set_mode((500, 500))

4
clock = pygame.time.Clock()

walls = [] # List to hold the walls


player = Player() # Create the player

# Holds the level layout in a list of strings.


level = [
"WWWWWWWWWWWWWWWWWWWWWWWW",
"W

W W",

"W

WWWWWW WW W",

"W WWWW
"W W

W W WWW",

WWWW

W",

"W WWW WWWW

W",

"W W

WW

WW W",

"W W

W WWWWWW W",

"W WWW WWW W W W W",


"W

W W W W W W",

"WWW W WWWWW W WWW",


"W WW
"W W

WW W",
WW WWWWWW W",

"W WWW WWW W W W W",


"W W W W W W W W",
"WWW
"W W

WWW W W",
WW W W W",

"W W WWWWWWWWWW W W",


"W

E W",

"WWWWWWWWWWWWWWWWWWWWWWWW",
]
5
# Parse the level string above. W = wall, E = exit
x=y=0

for row in level:


for col in row:
if col == "W":
Wall((x, y))
if col == "E":
end_rect = pygame.Rect(x, y, 16, 16)
x += 16
y += 16
x=0

running = True
while running:

clock.tick(60)

for e in pygame.event.get():
if e.type == pygame.QUIT:
running = False
if e.type == pygame.KEYDOWN and e.key == pygame.K_ESCAPE:
running = False

# Move the player if an arrow key is pressed


key = pygame.key.get_pressed()
if key[pygame.K_LEFT]:
player.move(-2, 0)
if key[pygame.K_RIGHT]:
player.move(2, 0)
if key[pygame.K_UP]:
player.move(0, -2)

if key[pygame.K_DOWN]:
player.move(0, 2)

# Just added this to make it slightly fun ;)


if player.rect.colliderect(end_rect):
raise SystemExit, "You win!"

# Draw the scene


screen.fill((0, 0, 0))
for wall in walls:
pygame.draw.rect(screen, (255, 255, 255), wall.rect)
pygame.draw.rect(screen, (255, 0, 0), end_rect)
pygame.draw.rect(screen, (255, 200, 0), player.rect() pygame.display.flip()

5 Screen Shots:

Start of the game

end of the game

6 Conclusion:
The Game is Created for the fun and entertainment.

7 Future Enhancements:
Further enhancements for the project would be able to add new levels.

7. References:
1. http://www.pygame.org/docs/ref/image.html
2. http://www.pygame.org/hifi.html
3. http://www.pygame.org/docs/ref/mixer.html
4. http://www.pygame.org/docs/

Вам также может понравиться