Author Topic: DrawSpriteRect  (Read 7291 times)

Offline Orpheus_2003

  • Mc. Print
  • *
  • Posts: 29
    • View Profile
    • CreativArtwork
DrawSpriteRect
« on: 2009-Sep-08 »
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....

Offline PeeJay

  • Mr. Polyvector
  • ***
  • Posts: 244
    • View Profile
    • PeeJays Remakes
Re: DrawSpriteRect
« Reply #1 on: 2009-Sep-08 »
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

Offline Orpheus_2003

  • Mc. Print
  • *
  • Posts: 29
    • View Profile
    • CreativArtwork
Re: DrawSpriteRect
« Reply #2 on: 2009-Sep-08 »
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.


Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5022
  • O Rly?
    • View Profile
Re: DrawSpriteRect
« Reply #3 on: 2009-Sep-08 »
Or you use SETSCREEN :)
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Orpheus_2003

  • Mc. Print
  • *
  • Posts: 29
    • View Profile
    • CreativArtwork
Re: DrawSpriteRect
« Reply #4 on: 2009-Sep-11 »
@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

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1775
    • View Profile
    • Homepage
Re: DrawSpriteRect
« Reply #5 on: 2009-Sep-11 »
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.

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5022
  • O Rly?
    • View Profile
Re: DrawSpriteRect
« Reply #6 on: 2009-Sep-11 »
Whoops... CREATESCREEN, sorry!
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1635
  • Particle Hawk
    • View Profile
Re: DrawSpriteRect
« Reply #7 on: 2009-Sep-11 »
ROTOZOOMSPRITE uses x y insertion and a scalar to resize it.
If you need it to be framed, ROTOZOOMANIM will work.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Orpheus_2003

  • Mc. Print
  • *
  • Posts: 29
    • View Profile
    • CreativArtwork
Re: DrawSpriteRect
« Reply #8 on: 2009-Sep-11 »
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.........

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1775
    • View Profile
    • Homepage
Re: DrawSpriteRect
« Reply #9 on: 2009-Sep-11 »
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.

Offline Orpheus_2003

  • Mc. Print
  • *
  • Posts: 29
    • View Profile
    • CreativArtwork
Re: DrawSpriteRect
« Reply #10 on: 2009-Sep-13 »
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??
« Last Edit: 2009-Sep-14 by Orpheus_2003 »

Offline Orpheus_2003

  • Mc. Print
  • *
  • Posts: 29
    • View Profile
    • CreativArtwork
Re: DrawSpriteRect
« Reply #11 on: 2009-Sep-13 »
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
« Last Edit: 2009-Sep-13 by Orpheus_2003 »

Offline Orpheus_2003

  • Mc. Print
  • *
  • Posts: 29
    • View Profile
    • CreativArtwork
Re: DrawSpriteRect
« Reply #12 on: 2009-Sep-14 »
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
« Last Edit: 2009-Oct-09 by Kitty Hello »

Offline FutureCow

  • HelpEditor
  • Prof. Inline
  • ******
  • Posts: 680
    • View Profile
Re: DrawSpriteRect
« Reply #13 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.

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.
« Last Edit: 2009-Oct-09 by FutureCow »

Offline PeeJay

  • Mr. Polyvector
  • ***
  • Posts: 244
    • View Profile
    • PeeJays Remakes
Re: DrawSpriteRect
« Reply #14 on: 2009-Oct-17 »
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