View previous topic :: View next topic |
Author |
Message |
Boscop
Joined: 26 Feb 2009 Posts: 29
|
Posted: Sat Mar 07, 2009 8:22 pm Post subject: Drawing on a sprite |
|
|
Is it possible in arclib to draw onto a sprite with arclib? I know that SDL handles them as surfaces that can also be drawing targets.
And what's the difference between normal blaze and arclib-blaze? _________________ A programmer is just a tool to convert coffeine into code! |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
|
Back to top |
|
|
Boscop
Joined: 26 Feb 2009 Posts: 29
|
Posted: Tue Mar 10, 2009 10:38 am Post subject: |
|
|
My question was if I can draw a sprite onto another sprite, i.e. using a sprite as a drawing buffer like it is possible with normal SDL.
Or is there a function to grab the contents of the screen?
Because in my game I need the ability to change sprites dynamically as the game proceeds. _________________ A programmer is just a tool to convert coffeine into code! |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Wed Mar 11, 2009 8:30 am Post subject: |
|
|
Please explain more... |
|
Back to top |
|
|
Boscop
Joined: 26 Feb 2009 Posts: 29
|
Posted: Wed Mar 11, 2009 9:19 am Post subject: |
|
|
Well, in my game I will have a static background image and a foreground image. And the foreground image is destructible like in worms, so I would want to draw an arc with 'transparent' color and dark carbonized border onto the foreground image each time a bomb explodes somewhere. (The collision stuff is handled apart from the graphics.) _________________ A programmer is just a tool to convert coffeine into code! |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Wed Mar 11, 2009 10:36 am Post subject: |
|
|
Ok... so I'd imagine you would have it work like this.
1. Store foreground image as an SDL_Surface* img
2. Load this image to be displayed as foreground
When damage occurs...
A. Edit the pixels you need to edit in the SDL_Surface* img with SDL's functions
B. Re-load the updated texture into OpenGL
I just made a change in the texture structure to allow you to access the images pixel data as an SDL_Surface*. From there you can manipulate it as you wish.
I had to add some new functions to the Texture struct to allow for this to happen.
http://arclib.blogspot.com/2009/03/texture-pixel-data.html
You should be able to accomplish your task, now. How are you going to handle collision detection? |
|
Back to top |
|
|
Boscop
Joined: 26 Feb 2009 Posts: 29
|
Posted: Wed Mar 11, 2009 12:01 pm Post subject: |
|
|
I will have polygons and circles. Polygons are solid and are there from the beginning, i.e. during the game no polygons will be added. Circles can be added anytime and they are either solid or hollow. When a circle is added, it searches for collisions with other shapes and tells them that within their bounds they are now responsible for detection, so that sth can be inside a hollow circle (crater) without colliding with the polygon the circle is in. When a circle has no more joints to other shapes (maybe s.o. threw a big bomb in a small crater) it gets marked for being freed. The same applies to polygons who are completely covered by hollow circles (hollow circles stay forever).
Using the approach of this method it is possible to e.g. place a polygon in a large hollow circle depending of the order of the shapes in the map xml file. Like in this order: poly1, circle, poly2. When circle is added it checks only for overlap between all previously added shapes (poly1 in this case)!
But not all polygons and solid circles are destructible. There will be some walls of metal.
Which part of arclib do I have to download for being able to use the function? Do I have to 'dsss net install' it from ground up? _________________ A programmer is just a tool to convert coffeine into code! |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Wed Mar 11, 2009 12:20 pm Post subject: |
|
|
texture.d is part of the arclib core
dsss net install arclib-core
should do the trick.
then just
Texture t = Texture("image.png");
t.getSDLSurface()
t.setSDLSurface(surf) |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Mon Mar 16, 2009 3:12 pm Post subject: |
|
|
http://arclib.blogspot.com/2009/03/texture-pixel-data.html
I'm changing to default behavior to not save the SDL surface. If you want to save the SDL surface of a specific texture, use
Texture t = Texture("tname.png", true);
which will save the SDL surface pixel data. Otherwise, that data will be destroyed as in 90% of cases you don't need it. |
|
Back to top |
|
|
Boscop
Joined: 26 Feb 2009 Posts: 29
|
Posted: Mon Mar 16, 2009 4:12 pm Post subject: |
|
|
I tried to install it via dsss but it says:
Quote: | Working in E:\dev\d2\dsss\tmp\DSSS_arclib-core
A arc
A arc\dsss.conf
A arc\arcmacros.ddoc
A arc\arc
A arc\arc\internals
A arc\arc\internals\input
A arc\arc\internals\input\joystick.d
A arc\arc\internals\input\keyboard.d
A arc\arc\internals\input\signals.d
A arc\arc\internals\input\all.d
A arc\arc\internals\input\mouse.d
A arc\arc\internals\input\constants.d
A arc\arc\internals\font
A arc\arc\internals\font\boxpacker.d
A arc\arc\internals\font\fontcache.d
A arc\arc\time.d
A arc\arc\input.d
A arc\arc\texture.d
A arc\arc\text
A arc\arc\text\all.d
A arc\arc\text\routines.d
A arc\arc\types.d
A arc\arc\font.d
A arc\arc\memory
A arc\arc\memory\freelist.d
A arc\arc\memory\all.d
A arc\arc\memory\routines.d
A arc\arc\math
A arc\arc\math\rect.d
A arc\arc\math\matrix.d
A arc\arc\math\angle.d
A arc\arc\math\all.d
A arc\arc\math\routines.d
A arc\arc\math\point.d
A arc\arc\math\size.d
A arc\arc\math\collision.d
A arc\arc\window.d
A arc\arc\all.d
A arc\arc\sound.d
A arc\arc\draw
A arc\arc\draw\color.d
A arc\arc\draw\shape.d
A arc\arc\draw\image.d
A arc\arc\draw\all.d
A arc\arc\templates
A arc\arc\templates\array.d
A arc\arc\templates\treestructure.d
A arc\arc\templates\singleton.d
A arc\arc\templates\all.d
Exported revision 1509.
arc\internals\input\joystick.d(10): module sdltypes cannot read file 'derelict\s
dl\sdltypes.d'
arc\input.d(86): module sdltypes cannot read file 'derelict\sdl\sdltypes.d'
arc\internals\input\joystick.d(10): module sdltypes cannot read file 'derelict\s
dl\sdltypes.d'
arc\input.d(86): module sdltypes cannot read file 'derelict\sdl\sdltypes.d'
arc\input.d(86): module sdltypes cannot read file 'derelict\sdl\sdltypes.d'
arc\input.d(86): module sdltypes cannot read file 'derelict\sdl\sdltypes.d'
derelict\sdl\sdltypes.d: module sdltypes cannot read file 'derelict\sdl\sdltypes
.d'
derelict\sdl\sdlfuncs.d: module sdlfuncs cannot read file 'derelict\sdl\sdlfuncs
.d'
Creating imports for arc_core
arc => arc_core
arc\internals\input\joystick.d(10): module sdltypes cannot read file 'derelict\s
dl\sdltypes.d'
Command E:\dev\d2\dsss\bin\rebuild.exe returned with code 1, aborting.
Error: Command failed, aborting. |
_________________ A programmer is just a tool to convert coffeine into code! |
|
Back to top |
|
|
Nthalk
Joined: 15 Jun 2008 Posts: 8
|
Posted: Mon Mar 16, 2009 11:54 pm Post subject: |
|
|
Boscop wrote: | I tried to install it via dsss but it says:
arc\internals\input\joystick.d(10): module sdltypes cannot read file 'derelict\s
dl\sdltypes.d'
arc\input.d(86): module sdltypes cannot read file 'derelict\sdl\sdltypes.d'
arc\internals\input\joystick.d(10): module sdltypes cannot read file 'derelict\s
dl\sdltypes.d'
arc\input.d(86): module sdltypes cannot read file 'derelict\sdl\sdltypes.d'
arc\input.d(86): module sdltypes cannot read file 'derelict\sdl\sdltypes.d'
arc\input.d(86): module sdltypes cannot read file 'derelict\sdl\sdltypes.d'
derelict\sdl\sdltypes.d: module sdltypes cannot read file 'derelict\sdl\sdltypes
.d'
derelict\sdl\sdlfuncs.d: module sdlfuncs cannot read file 'derelict\sdl\sdlfuncs
.d' |
Haha this is probably my fault. I told clay about how derelict updated their sdl lib. Just dsss net install derelict and you should be good again.
Sorry!
-Nthalk |
|
Back to top |
|
|
Boscop
Joined: 26 Feb 2009 Posts: 29
|
Posted: Wed Mar 18, 2009 1:03 pm Post subject: |
|
|
Thanks! _________________ A programmer is just a tool to convert coffeine into code! |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
|
Back to top |
|
|
Boscop
Joined: 26 Feb 2009 Posts: 29
|
Posted: Fri Mar 20, 2009 8:10 pm Post subject: |
|
|
When I now run the blaze demos (after compilation), it says:
Quote: | derelict.util.exception.DerelictException: Invalid library name |
However, the included parts Quote: | import derelict.opengl.gl;
import derelict.opengl.glu;
import derelict.sdl.sdl; | are all there.
I couldn't find out what's wrong with it... _________________ A programmer is just a tool to convert coffeine into code! |
|
Back to top |
|
|
clayasaurus
Joined: 21 May 2004 Posts: 857
|
Posted: Fri Nov 06, 2009 10:49 am Post subject: |
|
|
Hi,
Try using the derelict in the arclib trunk.
- Clay |
|
Back to top |
|
|
|