Coder Social home page Coder Social logo

realkevinapetrei / hilo Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 9.16 MB

HiLo is a minigame where you try to guess whether the next number will be higher or lower. As you play the game gets harder, losing and gaining points as you go...

License: GNU General Public License v3.0

Python 100.00%
minigame guessing-number-game fun

hilo's People

Contributors

realkevinapetrei avatar

Stargazers

 avatar

Watchers

 avatar

hilo's Issues

Problem in data storage? Use SQL and php

As I can see, you have some bugs with data reset and data storage in general. I was wondering why you store data in a .txt file and not into a database, like an SQLite3/SQL/MongoDB base even connected to a PHP server to store the data from every single player.

Python uses sqlite3 by default to manage Databases.

image

But it's also a good idea to use a nonrelational database system (DB) as MongoDB and pyMongo

image

In both cases is very simple to connect to the DDBB using python. I like to use functional decorators to do it but you can use other structures.

import sqlite3
def sqlconnect(func):
    def connect_to_sql( ):
        con = sqlite3.Conexion( )
        func( )
        con.close( )
    return connect_to_sql

@sqlconnect
def connect_and_say_hi( ):
     print('I am connected')
     #Add data or do something

And a tip; if you need to store data in local you should use a binary file, not a text one, and even convert the info to binary using Python itself.

data.txt / data

You can use the following code to change from text to binary using Python

foo = 'Hi, I am a text'
binary = ' '.join(format(ord(letter), 'b') for letter foo) #Change the text to binary
print(str(binary))

01001000 01101001 00101100 00100000 01001001 00100000 01100001 01101101 00100000 01100001 00100000 01110100 01100101 01111000 01110100

And then open a file in write mode with the pickle module

import pickle
file = pickle.open('data/file_to_open', 'w') #write mode
file.write(binary)
file.close( )

So, the code to open a binary something in a binary file would be:

user_data = ''
binary = ' '.join(format(ord(letter), 'b') for letter in user_data) #Change the text to binary
import pickle
file = pickle.open('data/file_to_open', 'w') #write mode
file.write(binary)
file.close( )

image

Fix buggy Labels in Tkinter

The UI is quite buggy when playing the game.

The text is redefined causing everything to be plastered over the current label.

This is a top priority fix.

High Score file empty after each run of game.

High Score file empty after each run of the game:

  • High Score Value on Label is Empty
if Player.score > int(current_high_score): # If score is higher than High Score
ValueError: invalid literal for int() with base 10: '

Causes error in code.

How to fix constant empty file after each run?

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.