cool.
Anyone know if there are any drawing functions other than sprites? like rects, lines etc?
cool.
Anyone know if there are any drawing functions other than sprites? like rects, lines etc?
I believe the only primitives supported are filled rectangle.
(I feel like I’m copying at my exams right now… )
Is it possible to detect whether a button is held down?
The button is held if there is “down” event , but not yet “up” event.
Can we access the header pins from micropython? I’d like to use my own button routines (https://os.mbed.com/users/spinal/code/HelloWorld_buttontest/) if possible. I’m having a couple of button issues and I’m curious if this would solve them.
Sure, in the slide set there is an example, how to read a “line following” sensor. That is how you can read any digital pin.
Of course, works only on HW.
@Hanski could you please add this to the FAQ at begin of the thread?
Can you confirm other random
methods (like randrange(star,stop) , randint(start,stop)) are not supported?
Also it seems like the seed is never updated. At least in the sim this code give me always the same result:
import urandom as random
print(random.getrandbits(8))
hmmm, it looks like only pins brought out to the PEX header are usable, is this right? I need some of the internal pins…
_aPin = Pin(Pin.P1_9, Pin.IN)
_bPin = Pin(Pin.P1_4, Pin.IN)
_cPin = Pin(Pin.P1_10, Pin.IN)
_upPin = Pin(Pin.P1_13, Pin.IN)
_downPin = Pin(Pin.P1_3, Pin.IN)
_leftPin = Pin(Pin.P1_25, Pin.IN)
_rightPin = Pin(Pin.P1_7, Pin.IN)
Added to the FAQ. The getrandbits() is the only function for getting random numbers.
I could probably add these.
I’d probably be the only one who uses them. If it’s more than a couple of seconds work don’t bother.
How do you draw a rectangle on the screen? In fact where can you see which functions are available?
Here are the gaming API functions listed: [Wiki]uPyGame & umachine library reference (for Micro Python in Pokitto)
You can only draw a filled rectangle.
Thanks. I had checked that list but somehow missed the fill function…
My solution is to use 2 images, 1 horizontal and 1 vertical line then just draw however many you need to the screen
Images? There’s no ‘draw line’ function? Or is it a speed thing?
Hrm, I wonder if image rendering is faster or slower than bresenham’s line algorithm…
I know, I couldn’t find anything other than drawing images or filling rects, so I did what anyone else would do. I used images of short lines and drew as many as I needed to create a rect.
As already two people were requesting drawing primitives, I am curious what you are doing with the primitives? I almost never use them in games.
I wanted to draw some lines and mistakenly thought I could use the filled rectangle function.
I always assumed that just drawing lines would be “better” in terms of “performance” than having to store and draw a whole bitmap of which most pixels are transparent. I currently don’t really need the lines though.
Particles, particles everywhere.
And lasers light beams.
Also debug hit box, 3d flat shaded triangles, landscapes.
If you are not a pixel artist primitives help a lot.