Skip to content

Commit 417a488

Browse files
committed
initial commit
1 parent 8872463 commit 417a488

9 files changed

+279
-2
lines changed

1. Display Image with pygame.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""Display Image With Pygame"""
2+
3+
import pygame
4+
5+
pygame.init()
6+
7+
display_width = 800
8+
display_height = 600
9+
gameDisply= pygame.display.set_mode((display_width, display_height))
10+
pygame.display.set_caption("Race Game")
11+
12+
black = (0, 0, 0)
13+
white = (255, 255, 255)
14+
15+
clock = pygame.time.Clock()
16+
carImg = pygame.image.load("img/image.jpeg")
17+
crashed = False
18+
19+
def car(x, y):
20+
gameDisply.blit(carImg, (x, y))
21+
22+
x = display_width * 0.45
23+
y = display_height * 0.8
24+
25+
while not crashed:
26+
for event in pygame.event.get():
27+
if event.type == pygame.QUIT:
28+
crashed = True
29+
30+
gameDisply.fill(white)
31+
car(x, y)
32+
33+
pygame.display.update()
34+
clock.tick(60)
35+
36+
pygame.quit()
37+
quit()

2. Moving an image in python.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import pygame
2+
3+
pygame.init()
4+
5+
display_width = 800
6+
disply_height = 600
7+
8+
gameDisplay = pygame.display.set_mode((display_width, disply_height))
9+
pygame.display.set_caption("moving an image in python")
10+
11+
black = (0, 0, 0)
12+
white = (255, 255, 255)
13+
14+
clock = pygame.time.Clock()
15+
crashed = False
16+
carImg = pygame.image.load("img/image.jpeg")
17+
18+
# add image in game
19+
def car(x, y):
20+
gameDisplay.blit(carImg, (x, y))
21+
22+
x = display_width * 0.50
23+
y = disply_height * 0.20
24+
25+
x_change = 0
26+
car_speed = 0
27+
28+
while not crashed:
29+
for event in pygame.event.get():
30+
if event.type == pygame.QUIT:
31+
crashed = True
32+
33+
if event.type == pygame.KEYDOWN:
34+
if event.key == pygame.K_LEFT:
35+
x_change = -5
36+
elif event.key == pygame.K_RIGHT:
37+
x_change = 5
38+
if event.type == pygame.KEYUP:
39+
if event.key == pygame.K_LEFT or event.key== pygame.K_RIGHT:
40+
x_change = 0
41+
##
42+
x += x_change
43+
44+
gameDisplay.fill(white)
45+
car(x,y)
46+
47+
pygame.display.update()
48+
clock.tick(60)
49+
50+
pygame.quit()
51+
quit()

CONTRIBUTING.MD

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Contributing
2+
3+
When contributing to this repository, please first discuss the change you wish to make via issue,
4+
email, or any other method with the owners of this repository before making a change.
5+
6+
Please note we have a code of conduct, please follow it in all your interactions with the project.
7+
8+
## Pull Request Process
9+
10+
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11+
build.
12+
2. Update the README.md with details of changes to the interface, this includes new environment
13+
variables, exposed ports, useful file locations and container parameters.
14+
3. Increase the version numbers in any examples files and the README.md to the new version that this
15+
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
16+
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
17+
do not have permission to do that, you may request the second reviewer to merge it for you.
18+
19+
## Code of Conduct
20+
21+
### Our Pledge
22+
23+
In the interest of fostering an open and welcoming environment, we as
24+
contributors and maintainers pledge to making participation in our project and
25+
our community a harassment-free experience for everyone, regardless of age, body
26+
size, disability, ethnicity, gender identity and expression, level of experience,
27+
nationality, personal appearance, race, religion, or sexual identity and
28+
orientation.
29+
30+
### Our Standards
31+
32+
Examples of behavior that contributes to creating a positive environment
33+
include:
34+
35+
* Using welcoming and inclusive language
36+
* Being respectful of differing viewpoints and experiences
37+
* Gracefully accepting constructive criticism
38+
* Focusing on what is best for the community
39+
* Showing empathy towards other community members
40+
41+
Examples of unacceptable behavior by participants include:
42+
43+
* The use of sexualized language or imagery and unwelcome sexual attention or
44+
advances
45+
* Trolling, insulting/derogatory comments, and personal or political attacks
46+
* Public or private harassment
47+
* Publishing others' private information, such as a physical or electronic
48+
address, without explicit permission
49+
* Other conduct which could reasonably be considered inappropriate in a
50+
professional setting
51+
52+
### Our Responsibilities
53+
54+
Project maintainers are responsible for clarifying the standards of acceptable
55+
behavior and are expected to take appropriate and fair corrective action in
56+
response to any instances of unacceptable behavior.
57+
58+
Project maintainers have the right and responsibility to remove, edit, or
59+
reject comments, commits, code, wiki edits, issues, and other contributions
60+
that are not aligned to this Code of Conduct, or to ban temporarily or
61+
permanently any contributor for other behaviors that they deem inappropriate,
62+
threatening, offensive, or harmful.
63+
64+
### Scope
65+
66+
This Code of Conduct applies both within project spaces and in public spaces
67+
when an individual is representing the project or its community. Examples of
68+
representing a project or community include using an official project e-mail
69+
address, posting via an official social media account, or acting as an appointed
70+
representative at an online or offline event. Representation of a project may be
71+
further defined and clarified by project maintainers.
72+
73+
### Enforcement
74+
75+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
76+
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
77+
complaints will be reviewed and investigated and will result in a response that
78+
is deemed necessary and appropriate to the circumstances. The project team is
79+
obligated to maintain confidentiality with regard to the reporter of an incident.
80+
Further details of specific enforcement policies may be posted separately.
81+
82+
Project maintainers who do not follow or enforce the Code of Conduct in good
83+
faith may face temporary or permanent repercussions as determined by other
84+
members of the project's leadership.
85+
86+
### Attribution
87+
88+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
89+
available at [http://contributor-covenant.org/version/1/4][version]
90+
91+
[homepage]: http://contributor-covenant.org
92+
[version]: http://contributor-covenant.org/version/1/4/

Pipfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[[source]]
2+
name = "pypi"
3+
url = "https://pypi.org/simple"
4+
verify_ssl = true
5+
6+
[dev-packages]
7+
8+
[packages]
9+
pygame = "*"
10+
11+
[requires]
12+
python_version = "3.7"

Pipfile.lock

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,34 @@
1-
# PyGame-Tutorial
2-
PyGame Tutorial in Python3
1+
# Pygame Tutorial
2+
3+
> Pygame is python framework for deveopment games in python.
4+
5+
<img src="./img/pygame_logo.gif" alt="pygame snake">
6+
7+
## How to Contribute
8+
9+
- Fork the project repository
10+
11+
> Find the project's repository on GitHub, and then "fork" it by clicking the Fork button in the upper right corner:
12+
13+
- Clone your Fork
14+
15+
> Using Git on your local machine, clone your fork using the URL you just copied: git clone URL_OF_FORK.
16+
17+
- Add the project repository as the "upstream" remote
18+
> Add the project repository as the "upstream" remote using: git remote add upstream URL_OF_PROJECT.Before tryingto push first sync it with upstream repository.
19+
20+
- Upstream Repository - where you forked your project
21+
- Origin Repository - Your forked project
22+
23+
**Check Details workflow here before submitting - https://dataschool.io/how-to-contribute-on-github/
24+
25+
## Contributors
26+
27+
<!-- Don't change under this line -->
28+
<!-- If you contributed to project then add your github link and link to your image-->
29+
30+
<table>
31+
<td>
32+
<tr><a href="https://github.com/aayushi-droid"><img src="https://avatars1.githubusercontent.com/u/59429424?s=460&u=9fe1f1e20bff25ba6f044990ceab7a5d5bc4d1d4&v=4" alt="aayushi-droid" style="height:80px;width :80px;border-radius:50%"></a></tr>
33+
</td>
34+
</table>

img/image.jpeg

5.46 KB
Loading

img/pygame_logo.gif

24.5 KB
Loading

requirements.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)