Compare commits
6 Commits
aa7bcccada
...
rpi-dev-me
Author | SHA1 | Date | |
---|---|---|---|
|
34d934fb4a | ||
|
7def89db02 | ||
|
d753058352 | ||
|
4aa8af306c | ||
|
195abbc5eb | ||
|
85557ebb1c |
10
README.md
10
README.md
@@ -1,11 +1,11 @@
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
|
|
||||||
Pocket Friends is a game where you raise your own little pocket friend! These pocket friends, called bloops, are great little companions to have! You can feed them, play with them, and watch them grow up!
|
Pocket Friends is a game where you raise your own little pocket friend! These pocket friends, called bloops, are great little companions to have! You can feed them, play with them, and watch them grow up!
|
||||||
|
|
||||||
~~You can download the latest release of Pocket Friends on the [releases page.](https://gitea.citruxx.com/ndyer/pocket-friends/releases)~~
|
~~You can download the latest release of Pocket Friends on the [releases page.](https://github.com/nickedyer/pocket-friends/releases)~~
|
||||||
There are currently no releases of the game. To install the current version on GitHub, follow the instructions below.
|
There are currently no releases of the game. To install the current version on GitHub, follow the instructions below.
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -13,13 +13,13 @@ There are currently no releases of the game. To install the current version on G
|
|||||||
## Installing From Source
|
## Installing From Source
|
||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
- Python 3.10 or greater
|
- Python 3.6 or greater
|
||||||
- Pip
|
- Pip
|
||||||
- Git
|
- Git
|
||||||
|
|
||||||
All you need to do to install Pocket Friends is install it with pip and you're good to go!
|
All you need to do to install Pocket Friends is install it with pip and you're good to go!
|
||||||
|
|
||||||
`pip install git+https://gitea.citruxx.com/ndyer/pocket-friends.git`
|
`pip install git+https://github.com/nickedyer/pocket-friends.git`
|
||||||
|
|
||||||
Now that the game is installed, just run it like you would any other Python program.
|
Now that the game is installed, just run it like you would any other Python program.
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ If you wish to build this version of Pocket Friends for Windows, you will need t
|
|||||||
requirements as to install it to your system from source. After you have done that,
|
requirements as to install it to your system from source. After you have done that,
|
||||||
issue the following:
|
issue the following:
|
||||||
```
|
```
|
||||||
git clone https://gitea.citruxx.com/ndyer/pocket-friends.git
|
git clone https://github.com/nickedyer/pocket-friends.git
|
||||||
cd pocket-friends
|
cd pocket-friends
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
pip install pyinstaller
|
pip install pyinstaller
|
||||||
|
@@ -1,29 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
Launch script for Pocket Friends.
|
Wrapper that launches the launch script.
|
||||||
"""
|
"""
|
||||||
import os
|
import pocket_friends.launch as launch
|
||||||
from pathlib import Path
|
|
||||||
import pygame
|
|
||||||
import sys
|
|
||||||
from pocket_friends.game_files.game import main as game_main
|
|
||||||
from pocket_friends.development.dev_menu import main as dev_menu_main
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
enable_dev = False
|
launch.main()
|
||||||
|
|
||||||
# enable dev mode if --dev argument is passed
|
|
||||||
if len(sys.argv) > 0:
|
|
||||||
for args in sys.argv:
|
|
||||||
if args == '--dev':
|
|
||||||
enable_dev = True
|
|
||||||
if args == '--delete-save':
|
|
||||||
save_dir = os.path.join(Path.home(), '.pocket_friends')
|
|
||||||
os.remove(save_dir + '/save.json')
|
|
||||||
|
|
||||||
if not enable_dev:
|
|
||||||
game_main()
|
|
||||||
else:
|
|
||||||
dev_menu_main()
|
|
||||||
|
|
||||||
pygame.quit()
|
|
||||||
sys.exit()
|
|
||||||
|
@@ -6,8 +6,12 @@ the hardware can be run without the actual hardware.
|
|||||||
# Constants used by RPi.GPIO
|
# Constants used by RPi.GPIO
|
||||||
BOARD = 0
|
BOARD = 0
|
||||||
IN = 0
|
IN = 0
|
||||||
|
OUT = 1
|
||||||
FALLING = 0
|
FALLING = 0
|
||||||
|
|
||||||
|
HIGH = 1
|
||||||
|
LOW = 0
|
||||||
|
|
||||||
|
|
||||||
def setmode(new_mode):
|
def setmode(new_mode):
|
||||||
"""
|
"""
|
||||||
@@ -28,6 +32,16 @@ def setup(channel, mode, initial=None, pull_up_down=None):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def output(channel, set):
|
||||||
|
"""
|
||||||
|
Fake function to set a fake channel output.
|
||||||
|
:param channel:
|
||||||
|
:param set:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def add_event_detect(channel, edge_type, callback=None, bouncetime=0):
|
def add_event_detect(channel, edge_type, callback=None, bouncetime=0):
|
||||||
"""
|
"""
|
||||||
Fake function to add a non-existent event detect.
|
Fake function to add a non-existent event detect.
|
||||||
@@ -43,7 +57,7 @@ def event_detected(channel):
|
|||||||
"""
|
"""
|
||||||
Fake function to detect an event. Always returns false.
|
Fake function to detect an event. Always returns false.
|
||||||
:param channel:
|
:param channel:
|
||||||
:return:
|
:return: False
|
||||||
"""
|
"""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@@ -29,6 +29,15 @@ def run_button_test():
|
|||||||
GPIOHandler.setup()
|
GPIOHandler.setup()
|
||||||
|
|
||||||
|
|
||||||
|
def backlight_test():
|
||||||
|
"""
|
||||||
|
Turns off the backlight for 5 seconds.
|
||||||
|
"""
|
||||||
|
GPIOHandler.turn_off_backlight()
|
||||||
|
time.sleep(5)
|
||||||
|
GPIOHandler.turn_on_backlight()
|
||||||
|
|
||||||
|
|
||||||
def clear_screen():
|
def clear_screen():
|
||||||
"""
|
"""
|
||||||
Clears the screen.
|
Clears the screen.
|
||||||
@@ -55,9 +64,9 @@ def quit_menu():
|
|||||||
|
|
||||||
def quit_with_error():
|
def quit_with_error():
|
||||||
"""
|
"""
|
||||||
Quits the menu with error code 3.
|
Quits the menu with error code 2.
|
||||||
"""
|
"""
|
||||||
exit(3)
|
exit(2)
|
||||||
|
|
||||||
|
|
||||||
def change_menu(new_menu):
|
def change_menu(new_menu):
|
||||||
@@ -96,6 +105,7 @@ def main():
|
|||||||
main_menu = Menu('Pocket Friends Dev Menu')
|
main_menu = Menu('Pocket Friends Dev Menu')
|
||||||
main_menu.add_option(Menu.Option('Start Game', start_game))
|
main_menu.add_option(Menu.Option('Start Game', start_game))
|
||||||
main_menu.add_option(Menu.Option('Button Test', run_button_test))
|
main_menu.add_option(Menu.Option('Button Test', run_button_test))
|
||||||
|
main_menu.add_option(Menu.Option('Backlight Test', backlight_test))
|
||||||
main_menu.add_option(Menu.Option('Restart Dev Menu', quit_with_error))
|
main_menu.add_option(Menu.Option('Restart Dev Menu', quit_with_error))
|
||||||
main_menu.add_option(Menu.Option('Shutdown Pi', change_menu, 'shutdown'))
|
main_menu.add_option(Menu.Option('Shutdown Pi', change_menu, 'shutdown'))
|
||||||
main_menu.add_option(Menu.Option('Restart Pi', change_menu, 'restart'))
|
main_menu.add_option(Menu.Option('Restart Pi', change_menu, 'restart'))
|
||||||
|
@@ -534,7 +534,7 @@ except ImportError:
|
|||||||
on_hardware = False
|
on_hardware = False
|
||||||
|
|
||||||
|
|
||||||
def game():
|
def game(screen_size):
|
||||||
"""
|
"""
|
||||||
Starts the game.
|
Starts the game.
|
||||||
"""
|
"""
|
||||||
@@ -543,10 +543,6 @@ def game():
|
|||||||
# Hide the cursor for the Pi display.
|
# Hide the cursor for the Pi display.
|
||||||
pygame.mouse.set_visible(False)
|
pygame.mouse.set_visible(False)
|
||||||
|
|
||||||
# The game is normally rendered at 80 pixels and upscaled from there. If changing displays, change the
|
|
||||||
# screen_size to reflect what the resolution of the new display is.
|
|
||||||
screen_size = 240
|
|
||||||
|
|
||||||
window = pygame.display.set_mode((screen_size, screen_size))
|
window = pygame.display.set_mode((screen_size, screen_size))
|
||||||
surface = pygame.Surface((game_res, game_res))
|
surface = pygame.Surface((game_res, game_res))
|
||||||
|
|
||||||
@@ -974,11 +970,11 @@ def game():
|
|||||||
draw()
|
draw()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main(screen_size=240):
|
||||||
"""
|
"""
|
||||||
Calls the game() function to start the game.
|
Calls the game() function to start the game.
|
||||||
"""
|
"""
|
||||||
game()
|
game(screen_size)
|
||||||
|
|
||||||
GPIOHandler.teardown()
|
GPIOHandler.teardown()
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
|
@@ -24,6 +24,9 @@ class Constants:
|
|||||||
'j_l': 13, # Joystick left
|
'j_l': 13, # Joystick left
|
||||||
'j_r': 16 # Joystick right
|
'j_r': 16 # Joystick right
|
||||||
}
|
}
|
||||||
|
hardware = {
|
||||||
|
'backlight': 37
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class GPIOHandler:
|
class GPIOHandler:
|
||||||
@@ -54,6 +57,8 @@ class GPIOHandler:
|
|||||||
GPIO.add_event_detect(Constants.buttons.get('j_l'), GPIO.FALLING)
|
GPIO.add_event_detect(Constants.buttons.get('j_l'), GPIO.FALLING)
|
||||||
GPIO.add_event_detect(Constants.buttons.get('j_r'), GPIO.FALLING)
|
GPIO.add_event_detect(Constants.buttons.get('j_r'), GPIO.FALLING)
|
||||||
|
|
||||||
|
GPIO.setup(Constants.hardware.get('backlight'), GPIO.OUT, initial=GPIO.HIGH)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def teardown():
|
def teardown():
|
||||||
"""
|
"""
|
||||||
@@ -69,3 +74,17 @@ class GPIOHandler:
|
|||||||
:return: True if the button is has been pressed, False otherwise
|
:return: True if the button is has been pressed, False otherwise
|
||||||
"""
|
"""
|
||||||
return GPIO.event_detected(button)
|
return GPIO.event_detected(button)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def turn_on_backlight():
|
||||||
|
"""
|
||||||
|
Turns on the TFT backlight.
|
||||||
|
"""
|
||||||
|
GPIO.output(Constants.hardware.get('backlight'), GPIO.HIGH)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def turn_off_backlight():
|
||||||
|
"""
|
||||||
|
Turns off the TFT backlight.
|
||||||
|
"""
|
||||||
|
GPIO.output(Constants.hardware.get('backlight'), GPIO.LOW)
|
46
pocket_friends/launch.py
Normal file
46
pocket_friends/launch.py
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import argparse
|
||||||
|
import pygame
|
||||||
|
import sys
|
||||||
|
from pocket_friends.game_files.game import main as game_main
|
||||||
|
from pocket_friends.development.dev_menu import main as dev_main
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""
|
||||||
|
Launch script for Pocket Friends.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Creates the parser object.
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
|
# Adds parser arguments.
|
||||||
|
parser.add_argument('-D', '--delete-save', action='store_true', help='Deletes the save file if it exists.')
|
||||||
|
parser.add_argument('-s', '--size', type=int, default=240, help='Sets the size of the window.')
|
||||||
|
parser.add_argument('--dev', action='store_true', help='Deletes the save file if it exists.')
|
||||||
|
|
||||||
|
# Parse the arguments given
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# If given the delete-save argument, delete the safe file
|
||||||
|
if args.delete_save:
|
||||||
|
save_dir = os.path.join(Path.home(), '.pocket_friends')
|
||||||
|
# Remove the file if it exists
|
||||||
|
try:
|
||||||
|
os.remove(save_dir + '/save.json')
|
||||||
|
print('Save file deleted.')
|
||||||
|
except FileNotFoundError:
|
||||||
|
print('Save file does not exist, cannot delete.')
|
||||||
|
|
||||||
|
# Set the screen size
|
||||||
|
screen_size = int(args.size)
|
||||||
|
|
||||||
|
if not args.dev:
|
||||||
|
game_main(screen_size)
|
||||||
|
else:
|
||||||
|
dev_main()
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
pygame.quit()
|
||||||
|
sys.exit()
|
@@ -1 +1 @@
|
|||||||
pygame~=2.1.2
|
pygame==1.9.4
|
4
setup.py
4
setup.py
@@ -15,12 +15,12 @@ setuptools.setup(
|
|||||||
license='GNU GPL-3.0',
|
license='GNU GPL-3.0',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type='text/markdown',
|
long_description_content_type='text/markdown',
|
||||||
url='https://gitea.citruxx.com/ndyer/pocket-friends',
|
url='https://github.com/nickedyer/pocket-friends',
|
||||||
packages=setuptools.find_packages(),
|
packages=setuptools.find_packages(),
|
||||||
# https://pypi.org/classifiers/
|
# https://pypi.org/classifiers/
|
||||||
classifiers=[
|
classifiers=[
|
||||||
],
|
],
|
||||||
install_requires=required,
|
install_requires=required,
|
||||||
python_requires='>=3.10',
|
python_requires='>=3.6',
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user