Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8604133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:29:41+00:00 2026-06-12T02:29:41+00:00

I am trying to write a text based game in Python, but have reached

  • 0

I am trying to write a text based game in Python, but have reached a problem. I have my character move from one position to another in the Console, but every time the user presses a key, the character disappears. In order to see the character again, the user must press a key. Here is my code:

import os
import msvcrt

class Frog:
    X = 0
    Y = 0

    def __init__(self, x, y):
            self.X = x
            self.Y = y

    def Draw(self):
            for y in range(self.Y):
                    print ""
            print ' ' * self.X + '#'



    def Update(self):
            if msvcrt.kbhit() == True:
                    if msvcrt.getch() == 'a':
                            if self.X > 0:
                                    self.X = self.X - 1
                    if msvcrt.getch() == 'd':
                                    self.X = self.X + 1
                    if msvcrt.getch() == 'w':
                                    self.Y = self.Y - 1
                    if msvcrt.getch() == 's':
                                    self.Y = self.Y + 1






frog = Frog(0,0)


def Draw():
    frog.Draw()
    os.system('cls')

 def Loop():

    while 1:      

                    frog.Update()
                    Draw()



Loop()

Does anyone know what is causing this? All help would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:29:43+00:00Added an answer on June 12, 2026 at 2:29 am

    You clear the screen immediately after drawing, rather than before drawing. Thus, the thing you just drew is erased.

    def Draw():
        frog.Draw()
        os.system('cls')
    

    Try switching the order:

    def Draw():
        os.system('cls')
        frog.Draw()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have been trying to write a program in python to read two text
I am trying to write a program that sends basic text files from one
I am trying to write three separate line in a text document based on
I am trying to write a program to simulate a card game. I have
I'm working on a text-based adventure game and I'm trying to externalise as much
So, me and two other friends are trying to make a text based game
I'm trying to write a piece of text over an existing web page based
Trying to write a python script to extract lines from a file. The file
I'm trying to write some Perl to convert some HTML-based text over to MediaWiki
I am trying to write text to my txt file. After the first write

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.