DrawSpriteRect

Previous topic - Next topic

Orpheus_2003

DrawSpriteRect pic$, x, y, start_x, start_y, breite, h?he [, frame]

An out-take of the loaded pic$ with spec. hight,width and startpos x,y will be draw onto x,y

pic$      - picture ID
x         - x coordinates
y         - y coordinates
start_x - x coordinates for startpoint in load pic.
start_y - y coordinates for startpoint in load pic.
width    -  width picture out-take
hight     -  hight picture out-take
frame    - frame if used...

That would be nice to draw some tilesets and a levelengine for jump&runs....

PeeJay

Polyvector will do that for you .... and more besides (like lighting effects)  :good:
www.peejays-remakes.co.uk
For games, remakes, and GL Basic Tutorials
Artificial Intelligence is no match for Natural Stupidity

Orpheus_2003

OK. Tanks.
I will have a look on it.
Thats the problem i mentioned. The documentation is very rare....

But very good support here. Thx.


Schranz0r

Or you use SETSCREEN :)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Orpheus_2003

@Schranz0r

What do you want to say with Setscreen?
With that command i can set up my resolution for the screen.

I need an command to draw some parts of an .png onto the screen.
For example to draw tiles for a levelengine.
I cant understand the relation to setscreen?

Greets M

Moru

You can draw onto a new sprite, storing the picture instead of having to redraw it every time the player is standing still. On the other hand you have to draw it twice as long as the player is moving since you still have to draw the new sprite on screen.

Schranz0r

Whoops... CREATESCREEN, sorry!
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Hemlos

ROTOZOOMSPRITE uses x y insertion and a scalar to resize it.
If you need it to be framed, ROTOZOOMANIM will work.
Bing ChatGpt is pretty smart :O

Orpheus_2003

Hi.

Thx for explanation.

But. In fact i need some other functions here.
Obviously, i have to make some functions for myselfe.
I need a special function, which loads a png, bmp into the memory. Then with the new function
i can draw some parts out of this picture onto the screen. With sprites?
So.
I have som DIM arrarys for the level  (1AA  1AB and so on)
And with that i will generate a tilemap onto the screen.

I?v looked on some tutorials with Polyvector. But its a little bit hard to convert blitz3D programms into GLBasic.
Not special the language. But there are some very cool commands in Blitz3D which are missing here in glBasic....
So i have to programm it by myselfe.
If i have a substantial progress i will share it with you.
Meanwhile:   thinking and woundering.........

Moru

If you want a tilemap there are a few examples in the forums and on some homepages. I think there was even a tutorial somewhere. What most of us do when doing tilemap is to just load the picture with LOADANIM and specify the size of each tile. Then we can use DRAWANIM to draw all tiles on the screen according to an array we have made previously. If you look up DRAWANIM in the help file you can see a small example of how to do it.

Orpheus_2003

#10
So please help me here. Im confused....

I tried to load the arrays. So they are OK now..

But when i want to use some comparisons it wont work.
I can print the dim array onto screen. I get  1AF 000 and so on:



But if i want to compare that and draw a sprite it wont work? Why??

Orpheus_2003

#11
SORRY...

I found that:  Forget the space room...?   :zzz: :zzz:



Sorry for the spaming....


And here my first Version, Wizard Engine from Blitz3D to GLBasic....
http://wizard.lexigame.de/datas/wizard.zip
Use Cursors to move
Use F10-F12 to see the array number
Use +/ - on Numpad for Strech
Use F1 to set back to 0

Orpheus_2003

#12
So my solution for this topic to draw tilesets is:

Types and Sprites.
- loadimage AS Tsprite
- set up the rows for the different lines in the picture 
- draw that with
   IF BMPZeile=1 AND Layer$[x+mapoffsetX][y+mapoffsetY]<>"000" THEN ZOOMSPRITE  player5.pic[BMPSpalte],x*32*strechx,y*32*strechy,strechx,strechy

So it works...
Look for my new spriteenginge...with 300 FPS....(instead of 48 FPS at Blitz3D)
glow=red,2,300]And here my first Version, Wizard Engine from Blitz3D to GLBasic....[/glow]
http://wizard.lexigame.de/datas/wizard.zip

FutureCow

#13
I'd love to see this command too.
In my case, I have a what you could think of as a set of selectable tiles where there are a lot more than fit on the screen at any time. The set of tiles can be scrolled left & right to find the one you want to select.
The tiles that get scrolled are created dynamically by the program, so there's no  image file I can load as animation frames.
Additionally, as the set of tiles can scroll, the first and last tiles on the screen will often be partial ones, so I can't just draw animation "frames" to the screen to get around the problem as drawanim doesn't support drawing partial frames.

My ideal solution is to create a bitmap as wide as there are tiles, then just draw the correct sized section from that large bitmap to the screen.

From what I can tell, my solution has to be
Code (glbasic) Select
Create screen (large)
Draw all sprites to the big "screen"
each frame, swap to the new screen
use grab sprite to grab the section I want to display
swap back to the back buffer
drawsprite


This seems a lot of overhead as opposed to a drawspriterect command.
I've never used polyvector, but the solution seems to be even worse
Code (glbasic) Select

Create screen (large)
Draw all sprites to the big "screen"
use grab sprite to grab this big image to a single sprite

each frame create a poly
Use 4 polyvector commands changing the tx value to the start of what I want to draw
endpoly

Again, this seems a lot more overhead (in terms of lines of code) then should be required.

My biggest problem with either of these methods though is that they aren't really intuitive whereas a drawspriterect is.

PeeJay

Quote from: FutureCow on 2009-Oct-09
I'd love to see this command too.
In my case, I have a what you could think of as a set of selectable tiles where there are a lot more than fit on the screen at any time. The set of tiles can be scrolled left & right to find the one you want to select.
The tiles that get scrolled are created dynamically by the program, so there's no  image file I can load as animation frames.
Additionally, as the set of tiles can scroll, the first and last tiles on the screen will often be partial ones, so I can't just draw animation "frames" to the screen to get around the problem as drawanim doesn't support drawing partial frames.

Okay, I'm confused - if I understand correctly, surely you need nothing more than any other scrolling tile based map? If so, the answer is very simple indeed.

At the screen edges, you do not need to draw "partial" frames - you simply draw them outside the dimensions of the screen - ie. if you have a sprite that is 64x64 pixels, you can quite happily draw it at -32,-32 and just the bottom right will be visible on the screen. Why over complicate matters?
www.peejays-remakes.co.uk
For games, remakes, and GL Basic Tutorials
Artificial Intelligence is no match for Natural Stupidity