Coder Social home page Coder Social logo

Comments (8)

peterbrittain avatar peterbrittain commented on July 23, 2024

Hi @seanbayou.

I'm glad your daughter liked the animations. It was to help inspire younger programmers that I originally wrote this code! The samples (and associated built in clases) are there to show you what is possible building up layers on top of a modest set of features provided by the Screen class.

The problem is that the complexity is what creates the coolest effects, so it is a question of building it up one step at a time.

When it comes down to it, all animations really just draw the image, wait then move it a little (maybe based on some input) and finally clear up any bits that were left behind. All the basic drawing and input required for this is covered in the Screen class. I would recommend that you start by reading the docs for this. They are here: http://asciimatics.readthedocs.org/en/stable/io.html

Once you've got the basics of drawing to a given location on the Screen, the simplest thing to do is probably to animate a ball (which you could represent with the letter 'O'). To start, let's just move it along a line. The program would be something like a call to Screen.wrapper() to get your Screen object and call your main loop. This main loop would then:

  1. Draw the ball at its current location - say (0, 0) to start.
  2. Sleep for a short time - say 0.1s.
  3. Clear the current location - by drawing a space character there instead.
  4. Update the current location - e.g. add 1 to the x coordinate.
  5. Return to the start of the loop until you hit the edge of the Screen.

Once you've got that working, you could enhance it by making it bounce back to the start by reversing the movement operation (step 4). This creates a program that bounces the ball off one side of the Screen.

Then you could generalize this to make it bounce forever on both sides. To make it stop you could bring in the keyboard by checking for a key press before sleeping to quit - e.g. "Q".

With that all done you could try generalizing to bounce all around the Screen - i.e. add the ability to move vertically too.

With that all done, why not add some colour? You could make it cycle through the basic 7 colours every time it bounces.

If you really wanted to push the boat out, you could then try to create 2 bats and recreate the classic 70s video game called Pong.

from asciimatics.

seanbayou avatar seanbayou commented on July 23, 2024

Thank you for this detailed reply - much appreciated!

Is this the correct place to ask newbie questions or is there a forum or similar? In case it is ok to ask questions here is one:

  1. How do I get "screen.print_at()" to print a character in a specific colour out of of 256 colours? Right now only options are 0-7 and bold versions, as far as I know.

from asciimatics.

peterbrittain avatar peterbrittain commented on July 23, 2024

You're welcome.

Since i'm the only one on the project at the moment, this is the only forum for questions. In answer to your latest one, you can just use the number directly. The list of all colour indeces can be found here: https://en.m.wikipedia.org/wiki/File:Xterm_256color_chart.svg

from asciimatics.

peterbrittain avatar peterbrittain commented on July 23, 2024

@seanbayou Just one final thought...

Did you say you were running on Windows? If so, you are limited to 16 colours (as covered here http://asciimatics.readthedocs.org/en/stable/troubleshooting.html#colours-not-working). In this case, the best you can do is use the A_BOLD attribute to get the brighter versions of your standard 8.

from asciimatics.

seanbayou avatar seanbayou commented on July 23, 2024

Yes running on Windows. I saw the program 256colour.py and just assumed it was possible.

from asciimatics.

peterbrittain avatar peterbrittain commented on July 23, 2024

Yeah - if you run that on Windows, you'll see that it does its best, but cuts down the colours to the palette available. Is there anything else I can help with, or shall I close this issue down now?

from asciimatics.

seanbayou avatar seanbayou commented on July 23, 2024

Thanks, close this issue now. Appreciate all your help.

from asciimatics.

peterbrittain avatar peterbrittain commented on July 23, 2024

Thanks. Will do.

BTW, I see that you are new to github... If you like my project, please show your support by starring it. See https://help.github.com/articles/about-stars/ for more details.

from asciimatics.

Related Issues (20)

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.