How do i spawn Boxes under a cursor

how do i program a skecth that when i press A a block is drawn and i dont have to have thousands of integers?

What thumnail?
You mean the title?
You can change that.

Frankly I have no clue what you’re asking.
Are you looking for arduboy.fillRect(x, y, w, h)?

Is this ‘block’ drawn at arbitrary points on the screen? Is it drawn under a cursor that you’re moving around? You need to provide more details.

@Cody17 even for you this one is cryptic!


yes a cursor. when you press a it places a block but with every block you need a x and y or do you?

1 Like

Ah, so you are going to move a cursor around the screen dropping boxes at random points. If every box you drop is to be redrawn on the screen in the next frame then you will need to retain is x / y positions in integers (ideally a point structure).

You can create an array of point structures to keep the dimensions. When the array is full, you could start overwriting the initial entries in a ‘follow your tail’ approach.

1 Like

I’ve made a sample with @filmote’s approach.
It’s by far not optimal but it should help you.

Check it out here.


Exactly what I had in mind!

If you move the cursor a blocksize at a time, you’re basically just creating a tilemap. I like the Gameboy approach for this(See section 3.2.3) since it extends well, you draw sequentially and it’s simple to implement. If you just have one type of block and it needs to be placeable anywhere(not just at fixed grid positions) then I vote for the Point approach from @Botisaurus.

1 Like

Yes you are right.
As said this i not optimal, but easy to understand.

1 Like