Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / DrawSprite Question..

Author
Message
David Gervais
Retired Moderator
19
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 8th Dec 2013 14:43
Attached is a 1x1 (single Pixel size) Pixel.png image.. White R255, G255, B255.....

My question is, could the DrawSprite command be used with this image to basically act like a 'Dot' command? If so, would it be a simple matter of creating a function like



Perhaps all this is for nothing, does AppGameKit have undocumented 'Draw' commands and already has a 'DrawDot'? The only Draw command I found was Drawline. (which I guess could be used to plot a dot on screen by doing a Drawline(1,1,1,1,255,255,255)) but the sample says that the Drawline only used virtual resolution which probably not get a single pixel plotted on screen.

Any help with getting a DrawPixel/PlotPixel/DrawDot type command or function would help. On the flip side I guess there would also need to be a GetDot command to see if a pixel is there or not, but some kind of workaround might also be needed.

Thanks for any help, Cheers!

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 8th Dec 2013 14:50 Edited at: 8th Dec 2013 14:58
the next v2 beta have rectangle commands with gardiant colors.

getdot is like id=GetImage( x, y, width, height )

you should only use for painting a map, not for real time.
the pixel size you can define self.
example



AGK 108 B19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 8th Dec 2013 17:35
Quote: "could the DrawSprite command be used with this image to basically act like a 'Dot' command?"

Yes it could, but you would have to call it every frame (or each time the buffer is redrawn)

For a more "permanent" dot, you could use clonesprite(), but that might lead to a lot of sprites.

AGK can handle a heck of a lot of sprites, but you wouldn't want to fill a screen with them at that size.
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 8th Dec 2013 20:19 Edited at: 8th Dec 2013 20:49
108.12 changed DrawLine() to draw lines less than 1 pixel as a dot. Will this work for you?

EDIT: Markus has the right info.

Which begs the question, "How do you make a drawing program in AppGameKit without grabbing the whole screen image each cycle?" Can it even be done?

David Gervais
Retired Moderator
19
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 8th Dec 2013 21:52 Edited at: 8th Dec 2013 22:43
Hi, thanks for the replies,

Basically I'm thinking about redoing an old game I made first in Quick Basic 45 then I converted it to C++ (using DevCPP and MinG C++ and the Allegro Lib), the game has a Laser beam being drawn one pixel at a time.. even back on the 486 machine it was killer fast, and I had to slow it down. (I even used the speed as a feature, after you placed the mirrors to deflect the laser from the emitter to the cap, I had a 'Blitz' button that removed the slow down and it basically bounced off the mirrors at light speed and finished the level.

Anyways, I'm not sure how I'm going to tackle it, but since the lasers only move vertically and horizontally, I might figure out a way to use the SpriteResize/Scale thing to do what needs to be done.. but then I'll have the problem of seeing if the laser hit the lens/mirror with pixel perfect precision. Allegro had a Getpixel and PlotPixel command iirc.. I'll need to dig out my old C++ source for the game and see if it's possible to get a workaround.

again, thanks for the replies.

Cheers!

EDIT: found this old screenshot of the game on a backup CD.. might give you a better idea of what I meant by lasers, emitters and caps etc.. at later levels you could have up to 12 lasers moving at the same time, I had 'splitters' that split the beam into 2 or 3.. so on some levels you could have 1 emitter and 3 caps.. you start with 1 laser moving then you need to split it to be able to get the laser to all 3 caps.. it was a fun game.



Cheers v2.0

Attachments

Login to view attachments
fog
21
Years of Service
User Offline
Joined: 5th Oct 2003
Location: Newcastle, England
Posted: 9th Dec 2013 13:56
That looks like it would be much easier done using a simple grid based system for everything.

You have no need to worry about a pixel perfect collision system as it can be done just as accurately using tile locations and grid co-ordinates.

Your laser beams are then just a snake-like chain of sprite objects that move within that grid. (generated at the emitters, turn at mirror tiles etc.)

Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 9th Dec 2013 15:57
I would probably approach this by using a sprite for each line. You could use the same 1 pixel image and adjust the sprite size to get the line length.

By setting the sprite offset to 0,0 and positioning the sprite at the source of the line - either emitter or mirror - you would use sprite width for the line length and sprite rotation for direction (with 0 degrees being left to right).

So to make the line extend a pixel at a time, you would just need to change the width a pixel at a time and with the offset at 0,0, the line would extend in the direction given by the rotation.
David Gervais
Retired Moderator
19
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 9th Dec 2013 16:29
Hello again,

Thanks Fog and Marl, two excellent ideas and my thoughts ended up around these two suggestions.. the Emitters, Mirrors and End Caps are all placed using a grid system, and I think the dynamic scaling of a laser sprite is the right way to go.. I will need to do some tests, but I think that solved the big problem.

Thanks again for your suggestions.

Cheers!

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th Dec 2013 19:30 Edited at: 9th Dec 2013 19:35
you can do this also with a line-line intersect/reflect function.
here is some code i had made.
it used a list of walls.



not agk basic


AGK 108 B19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670

Attachments

Login to view attachments
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Dec 2013 05:54
Here is also an example of that laser game I did, which also animates the laser (shows it firing slowly).
http://forum.thegamecreators.com/?m=forum_view&t=203039&b=6

Login to post a reply

Server time is: 2024-11-24 23:40:47
Your offset time is: 2024-11-24 23:40:47