Git Product home page Git Product logo

billiards's Introduction

Billiards

This is a project I worked on between June 2020 and April 2021 for my A-Level Computer Science project. It was my first time exploring a low-level language* and I was learning as I went along, so much of the code is suboptimal. For example, I didn't discover what the intended purpose of header files were until after the project; where I was using a header file for the graphical output and mouse input, I just assumed that you only use one .cpp (or equivelant) file, and include additional functionality from header files. While I did know that C++ is a more performant language than Python (where the majority of my programming experience was at the time), I didn't know about Garbage Collectors or Memory Safety. This means that the project will inevitably have memory leaks, and I hope to revisit the project some time to find and fix them. I have also noticed naming inconsistencies and undesirable scoping, which wouldn't be present if I was to recreate the project today.

* C++ is considered a high-level language as it abstracts much of the detail away from the equivelant in machine code, but as you don't get as much help as you do in Python for example, so you can consider C++ to be a 'lower' level than Python.

The graphical output and keyboard input of this project was handled by One Lone Coder's Pixel Game Engine header file.
I remember struggling for quite some time trying to find a C++ graphics library that had everything I needed and was easy enough for 16-year-old me to understand, and the olcPixelGameEngine was that, so thank you javidx9 / David for making the olcPGE, as the project likely wouldn't have been possible at all without it.

For those who are interested, there are approximately 1400 lines of code.

Billiards-PoolDemo.mp4

Demos on YouTube:

- Pool
- Snooker

Controls

In this version of Billiards, you have two aiming stages, free aim, and power mode.
You start in free aim mode, where your aim marker will follow your cursor and indicate where the ball should start accelerating towards.

image

When the left mouse button is pressed, you enter into power mode. You will see a red and a yellow circle appear around the spot where you clicked. The aim marker will no longer track your cursor’s position, but a newly visible power marker will. The power of your shot is based on the distance between the aim marker and the power marker.
To take the shot, release the left mouse button.
The power marker will not track your cursor outside of the Max Power Radius, and if the left mouse button is released while the power marker is inside the Min Power Radius, the shot will be cancelled.

image

billiards's People

Contributors

bentaylor25 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.