forums

TNT Basic Forums > Programming Q&A
Drawing Snafu with Map Viewport
< Last Thread     Next Thread >
Author
Thread        Post A Reply

11-18-2003 23:49

Posted by:
buddy

Location:
Champaign, IL

Click Here to Email buddy   Find more posts by buddy

This is not a bug, it's just something that I don't think I can do the way TNTBasic currently works.

I have a topdown game where the player is running around. This uses a Map Viewport. Everything is great, until I try to implement one of the character's new weapons.

The weapon is supposed to be like a supernova... when fired, it radiates outward from the player's position in a circle, destroying enemies in its path as it expands.

I was trying to do this with FrameOval, drawing to the canvas of my Map Viewport.

As the circle gets larger, it eventually crashes TNTBasic. I think that is because the FrameOval is trying to draw using coordinates that technically do not exist on the canvas.

i.e. if the Map Viewport is set up as 640 x 480....
Once my supernova oval has its bounds outside of that 640x480 + whatever overlap the Map Viewport, it's crash time.

I do believe I could do this function IF I opened another canvas and had it be the same size as the game's Map. I could draw the oval to that map and then copy the portion of the Map I needed into my Map Viewport's canvas.

However, that new canvas would be too huge... negating the benefits of using Map Viewport in the first place.

I don't know of any other way to do this with the drawing commands, since it necessitates sometimes drawing to coordinates that are not actually existing in the "canvas" although they do exist on the Map.

What I'll probably do is have the "nova weapon" actually emit like 180 to 360 sprites that radiate outward. The sprites will be like player shots, I suppose.

BUT...
If anyone has any other cool ideas as to how I could get the oval method to work, I'd still prefer that (it looks cooler, too...)

Buddy

11-19-2003 18:41

Posted by:
mark_667

Location:
England

Click Here to Email mark_667   Find more posts by mark_667

I recommend you post the relevant part of your existing code, it may actually be another part of it that is causing TNT to crash and we could also better advise you on suggestions on how to make it look better, which I think you mentioned in your post. If you cannot get the draw oval commands to work, maybe you should consider using sprite animations for your explosions instead. This may be slightly slower, but will require less math on your part to work out the incrementation of the radius as it expands from the centre, etc. There are a couple of games in the directory section which use this method I think. And if you suspect the oval function is causing the crash, post it in the bugs forum there are some people there who'll only be too happy to investigate. But to save some time, is it only this latest version of TNT that is affected? Are there any errors displayed, or does it just crash?
hope some of this has been useful in someway,
Mark_667

11-19-2003 23:01

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

You could try making the nova a sprite. Sprites can go off canvas, so you could put the nova on the map viewport canvas. You just have to pre render the nova.

11-20-2003 14:22

Posted by:
buddy

Location:
Champaign, IL

Click Here to Email buddy   Find more posts by buddy

Yeah, I've started the effect with several sprites, radiating outward, and that will work but is slower and doesn't look the way I want it to.

HOWEVER...
I turned draw tracking off before drawing the oval, then turned it back on after drawing it, and used inval rect to tell tntbasic where precisely to refresh (which is just the area in the viewport anyway)... and now this "out of bounds drawing" of the oval does not crash.

I'll have to tweak it to get it to look like I want, but I might be able to pull it off.

In my murky mind, I'm wondering if drawing to the out of bounds area in a map viewport was actually addressing memory outside of the memory assigned to the canvas, therefore tromping the program...

Anyway, onward.

11-24-2003 23:03

Posted by:
Mark Tully

Location:
TNT HQ, England

Click Here to Email Mark Tully   Find more posts by Mark Tully

If you can produce a small program demonstrating this crash and email it me it would be very useful.

Cheers,

Mark

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.