Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snake game with Processing3 #80

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions projects/Get_Html/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Get The HTML Code

![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=102)

#100daysofcode This simple programe written in python with beautifulsoup module and the requests library.<br>
This programe allows you to get the html code from any website.<br>
Click <a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/"> here </a> to read more about beautifulsoup.<br>
Click <a href="https://requests.readthedocs.io/en/master/"> here </a> to read more about requests.

## Features :dart:
* [x] Free & Open Source
* [x] Very Easy to use

## Screenshot
Home | Paste The Link
:---------------------: | :-----------------:
![screenshoot](screenshots/gh1.png) | ![screenshoot](screenshots/gh2.png)
Get The Code | Simple Question
![screenshoot](screenshots/gh3.png) | ![screenshoot](screenshots/gh4.png)

## Requirements
* python
* beautifulsoup
* requests

## How To Use It
1. Download Python from this link: https://www.python.org/downloads/
2. Install the packeges, write in your command (cmd):
```bash
pip install beautifulsoup4
pip install requests
```
3. Install this repository, click <a href="https://github.com/mohamedyanis/covid19-tracker2/archive/master.zip"> here </a> to install it.
4. Extract the folder
5. Run the ```gethtml.py``` file

## Contributing 💡
If you want to contribute to this project and make it better with new ideas, your pull request is very welcomed.<br>
If you find any issue just put it in the repository issue section, thank!<br><br>
.سبحَانَكَ اللَّهُمَّ وَبِحَمْدِكَ، أَشْهَدُ أَنْ لا إِلهَ إِلأَ انْتَ أَسْتَغْفِرُكَ وَأَتْوبُ إِلَيْ
14 changes: 14 additions & 0 deletions projects/Get_Html/gethtml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from bs4 import BeautifulSoup
import requests
c = True
while c:
url =input('Enter The Url Here: ')
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')
print(soup.prettify())
cc = input('''

Do You Want To Scrap Another WebSite (Y/N): ''')
if cc.lower() == 'n':
print('Thanks..!')
c = False
Binary file added projects/Get_Html/screenshots/gh1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/Get_Html/screenshots/gh2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/Get_Html/screenshots/gh3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/Get_Html/screenshots/gh4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions your_projects/snake_game/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Snake Game

![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=102)

#100daysofcode This simple programme written with processing3 (like JAVA but easier).<br>
Click <a href="https://processing.org"> here </a> to read more about processing3.

## Features :dart:
* [x] Free & Open Source
* [x] Very Easy to use

## Thank _You_!
Please :star: this repo to help us improve the quality.

## Requirements
* processing3

## How To Use It
1. Download Processing3 from this link: https://processing.org/download/
2. Install this repository.
3. Extract the folder.
4. Open the ```snake_game.pde``` file.
5. Run it :)

## Contributing 💡
If you want to contribute to this project and make it better with new ideas, your pull request is very welcomed.<br>
If you find any issue just put it in the repository issue section, thank!<br><br>
.سبحَانَكَ اللَّهُمَّ وَبِحَمْدِكَ، أَشْهَدُ أَنْ لا إِلهَ إِلأَ انْتَ أَسْتَغْفِرُكَ وَأَتْوبُ إِلَيْ
139 changes: 139 additions & 0 deletions your_projects/snake_game/snake_game.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
ArrayList<Integer> x = new ArrayList<Integer>(), y = new ArrayList<Integer>();
int w = 30, h = 30, bs = 20, dir = 2, foodx = 10, foody = 10, score = 0;
int[] dx = {0,0,1,-1}, dy = {1,-1,0,0};
boolean gameOver = false;

void setup()
{
size(600, 600);
x.add(5);
y.add(5);
}


void draw()
{
if(!gameOver)
{
background(255);
fill(0);
textAlign(LEFT);
text(score, 70, 20);
rect(foodx*bs, foody*bs, bs, bs);
for(int i = 0; i<x.size(); i++){
noStroke();
fill(0,255,0);
rect(x.get(i)*bs, y.get(i)*bs, bs, bs);
}

if(frameCount%5 == 0)
{
x.add(0,x.get(0)+dx[dir]);
y.add(0,y.get(0)+dy[dir]);
if(foodx == x.get(0) && foody == y.get(0)){
score += 5;
foodx = (int)random(0,w);
foody = (int)random(0,h);
}
else{
x.remove(x.size()-1);
y.remove(y.size()-1);
}
}
if(x.get(0) < 0 || x.get(0) >= w || y.get(0) <0 || y.get(0) >=h)
{
delay(2000);
gameOver = true;
score = 0;
}
for(int i = 1; i < x.size()-1; i++)
{
if(x.get(i) == x.get(0) && y.get(i) == y.get(0))
{
delay(2000);
gameOver = true;
score = 0;
}
}
}
else{
background(0);
textSize(20);
textAlign(CENTER);
text("GAME OVER! \nPRESS SPACE TO PLAY AGAIN OR ESC TO EXIT)", width/2, height/3);
if(keyPressed && key == ' ')
{
x.clear();
y.clear();
x.add(5);
y.add(5);
gameOver = false;
}
}
}


void keyPressed()
{
int newDir;
if(key == CODED)
{
switch(keyCode){
case DOWN: newDir = 0; break;
case UP: newDir = 1; break;
case RIGHT: newDir = 2; break;
case LEFT: newDir = 3; break;
default: newDir = -1; break;
}//end switch
}//end if
else
{
switch(key){
case 's': newDir = 0; break;
case 'w': newDir = 1; break;
case 'd': newDir = 2; break;
case 'a': newDir = 3; break;
default: newDir = -1; break;
}//end switch
}//end else

switch(newDir){
case 0: {
if(dy[dir] == -1)
{
break;
}else {
dir = newDir;
break;
}//end if/else
}//end case0
case 1: {
if(dy[dir] == 1)
{
break;
}else {
dir = newDir;
break;
}//end if/else
}//end case1
case 2: {
if(dx[dir] == -1)
{
break;
}else {
dir = newDir;
break;
}//end if/else
}//end case2
case 3: {
if(dx[dir] == 1)
{
break;
}else {
dir = newDir;
break;
}//end if/else
}//end case3
}//end switch

}