fishies / sf-snake Goto Github PK
View Code? Open in Web Editor NEWSimple Fast Snake: The classic game Snake hacked together while learning the SFML framework.
Simple Fast Snake: The classic game Snake hacked together while learning the SFML framework.
Would it be better to draw using sf::VertexArray?
(Maybe data representation might also only keep vertices of the snake rather than every block... but computation would not be as consistent; a player who changes directions more often would have a more computationally expensive game. Not sure if this second idea would be better in every scenario. For which scenarios do I want to optimize?)
Allow the player to customize game options such as keybinds, size of level, speed of game. This may require a menu screen.
This one is relatively straightforward to implement; just check the food's spawn spot against the tail hash set before making the placement.
Wall collision is checked in GameBoard::update() and tail collision is checked in PlayerPiece::step(). Should reorganize code.
The game currently lacks music and sound. Such critical components of any properly polished game should not be neglected.
Currently the game's collision checking logic is O(1) due to use of a hash set. However, the hash set is used alongside a queue for O(1) tail growth/movement. Therefore the space complexity is O(2n) -- still linear, but is it good enough?
We can eliminate the need for a queue with some changes to what we put into the hash set; we want to track the "age" (that is, the game tick number on which the tail block was generated) of each tail block and pop off the oldest one with each step.
So we want to:
Proposed solutions:
Currently when the player selects a direction to turn, input is locked until the next frame. Therefore at times the game's controls will feel unresponsive. The proposed solution is to replace input locking with a Direction variable that always accepts input deciding what direction the snake will turn in the next step (so actual direction change is not processed until the start of the next frame).
Currently sf-snake uses cstdlib's rand function, even though this is supposed to be a C++11 project. The C RNG in this code should be replaced with C++11 library function(s).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.