Space Shooter v3

Test this app for free
39
from flask import jsonify
import logging
from flask import Flask, render_template, request, redirect, url_for, flash
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user, current_user
from werkzeug.security import generate_password_hash, check_password_hash
from gunicorn.app.base import BaseApplication

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

app = Flask(__name__)
app.config['SECRET_KEY'] = 'your_secret_key'  # Change this to a random secret key
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///users.db'
db = SQLAlchemy(app)
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'login'

class User(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True, nullable=False)
    password = db.Column(db.String(120), nullable=False)
    score = db.Column(db.Integer, default=0)
Get full code

Created: | Last Updated:

A Space shooter game where you have bunch of enemies to kill coming from all directions like waves

Introduction to the Space Shooter v3 Template

The Space Shooter v3 template is a dynamic and engaging space shooter game where players defend against waves of enemies coming from all directions. This template includes user authentication, a leaderboard, and a game interface built with HTML, CSS, JavaScript, and Flask.

Getting Started

To get started with the Space Shooter v3 template, click Start with this Template.

Test

Press the Test button to deploy the app and launch the Lazy CLI. This will set up the environment and start the application.

Entering Input

The application requires user input for authentication and gameplay. Follow these steps:

  1. Sign Up:
  2. Navigate to the sign-up page.
  3. Enter a username and password to create a new account.
  4. Click the Sign Up button.

  5. Login:

  6. Navigate to the login page.
  7. Enter your username and password.
  8. Click the Login button.

Using the App

Once logged in, you will be directed to the game interface. Here’s how to use the app:

  1. Start the Game:
  2. Click the Start Game button to begin playing.
  3. Use the arrow keys or WASD keys to move your player.
  4. Click and drag the mouse to aim and release to shoot projectiles at enemies.

  5. View Leaderboard:

  6. Click the Leaderboard button to view the top scores.
  7. The leaderboard will display the top 10 players and their scores.

  8. Logout:

  9. Click the Logout link in the navigation bar to log out of your account.

Integrating the App

The app includes a leaderboard feature that can be integrated into other services. Here’s how to access the leaderboard data:

  1. Get Leaderboard Data:
  2. The leaderboard data can be accessed via the /get_leaderboard endpoint.
  3. This endpoint returns a JSON response with the top 10 players and their scores.

Sample Request

http GET /get_leaderboard HTTP/1.1 Host: your-app-url Authorization: Bearer <your-auth-token>

Sample Response

json [ {"username": "player1", "score": 1500}, {"username": "player2", "score": 1200}, {"username": "player3", "score": 1100}, ... ]

Conclusion

The Space Shooter v3 template provides a fun and interactive way to build a space shooter game with user authentication and a leaderboard. Follow the steps above to set up, test, and use the app. Enjoy defending against waves of enemies and aim for the top of the leaderboard!

Technologies

Similar templates