Comments (8)
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:
- Draw the ball at its current location - say (0, 0) to start.
- Sleep for a short time - say 0.1s.
- Clear the current location - by drawing a space character there instead.
- Update the current location - e.g. add 1 to the x coordinate.
- 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.
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:
- 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.
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.
@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.
Yes running on Windows. I saw the program 256colour.py and just assumed it was possible.
from asciimatics.
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.
Thanks, close this issue now. Appreciate all your help.
from asciimatics.
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)
- Fatal Error when Multiple Frames in a scene with widgets HOT 3
- Better docs for callbacks
- RadioButton value equals None when set to False HOT 1
- Asciimatics doesn't print anything. HOT 3
- Custom subprocess integration HOT 2
- Rain test fails randomly HOT 10
- Load another form after initialization HOT 5
- RayCaster sample "swallows" key when commenting out RayCaster effect HOT 6
- DarkGray access on Windows/Powershell? HOT 7
- Automate user inputs HOT 4
- Leave and re-enter asciimatics mode? HOT 2
- Emojis with "hidden characters"? HOT 11
- particles HOT 4
- Mouse Events in Win11 HOT 4
- Implementing Widget's Custom Color Palettes HOT 4
- Can we donate to the project via Paypal? HOT 3
- New release? HOT 3
- Incompatible with Python 3.12 (imp module removed)
- Support multi-line text rolling in a rect HOT 3
- The effect of selecting the check box in version 1.15.0 is different from that in version 1.14.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asciimatics.