Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Programming_Project_Group_14
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
s2032074
Programming_Project_Group_14
Commits
429f72b2
Commit
429f72b2
authored
4 years ago
by
s2032074
Browse files
Options
Downloads
Patches
Plain Diff
deleted block.py as it is under further development on sequence branch
parent
19825055
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Block.py
+0
-67
0 additions, 67 deletions
Block.py
with
0 additions
and
67 deletions
Block.py
deleted
100644 → 0
+
0
−
67
View file @
19825055
'''
Block object which will be used in a corsi-blocks test
'''
#pygame is the library for drawing
import
sys
import
pygame
class
Block
:
'''
Block class defines the main functions that can be done with the block
'''
#Constructor to initiate a block (square)
#x and y -- coordinates of the top left corner
#length -- the length of one side of the square
#pressed -- is the boolean variable for detecting whether a user clicked on the block
def
__init__
(
self
,
x
,
y
,
length
,
pressed
):
self
.
x_coord
=
x
self
.
y_coord
=
y
self
.
length
=
length
self
.
pressed
=
pressed
def
draw_block
(
self
,
screen
):
'''
function for drawing a block with initialized parameters
'''
if
self
.
pressed
:
pygame
.
draw
.
rect
(
screen
,
(
169
,
169
,
169
),
(
self
.
x_coord
,
self
.
y_coord
,
self
.
length
,
self
.
length
),
0
)
else
:
pygame
.
draw
.
rect
(
screen
,
(
0
,
0
,
0
),
(
self
.
x_coord
,
self
.
y_coord
,
self
.
length
,
self
.
length
),
0
)
def
clicked
(
self
,
screen
,
event
):
'''
function for detecting whether a user has pressed on the block
'''
if
event
.
type
==
pygame
.
MOUSEBUTTONDOWN
and
event
.
button
==
1
:
coord_x
,
coord_y
=
pygame
.
mouse
.
get_pos
()
if
coord_x
>=
self
.
x_coord
and
coord_x
<=
self
.
x_coord
+
self
.
length
and
coord_y
>=
self
.
y_coord
and
coord_y
<=
self
.
y_coord
+
self
.
length
:
self
.
pressed
=
True
self
.
draw_block
(
screen
)
#this class will be tested, thus, we need this main method
#as it sets the environment where we are going to test
def
main
():
'''
This is MAAAAIN
'''
#defining the screen parameters
pygame
.
init
()
width
=
1000
height
=
800
pygame
.
display
.
set_mode
((
width
,
height
))
screen
=
pygame
.
display
.
get_surface
()
screen
.
fill
((
255
,
255
,
255
))
#creating an object
pressed
=
False
block1
=
Block
(
100
,
100
,
50
,
pressed
)
#drawing initial block
block1
.
draw_block
(
screen
)
pygame
.
display
.
update
()
#checking and updating the color when the block is clicked
while
True
:
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
pygame
.
QUIT
:
pygame
.
quit
()
sys
.
exit
()
block1
.
clicked
(
screen
,
event
)
pygame
.
display
.
update
()
#class functions testing
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment