Easier rotation?
BlitzMax Forums/BlitzMax Beginners Area/Easier rotation?
| ||
Hi, I'm new (like, last night new) to blitzmax, transferring from c++/blitz3d, and I'm wondering if there's an easier way to rotate images than setrotation, draw, setrotation, draw, etc. (forgive me if I have no idea what I'm talking about) is it possible to extend the TImage type to hold a rotation attribute, so whenever drawimage() is called, by default it rotates the image? any help is appreciated! |
| ||
Wouldn't you have something like (typed straight into reply box so untested, but you get the idea):Aliens:tAliens = new tAliens Aliens.Add() Aliens.Draw() Type tAliens Field list:TList = New TList Method add() local alien:tAlien = new tAlien 'set alien attributes here Self.list.AddLast alien End Method Method draw() Local alien:tAlien For alien = EachIn Self.list SetRotation alien.angle DrawImage alien.image, alien.x, alien.y Next SetRotation 0 End Method End Type Type tAlien Field x:Float Field y:Float Field angle:Float Field image:TImage End Type |
| ||
yeah, that would work, except it seems kind of needless to do that for every project you make, wouldn't it just be more efficient to add an attribute to TImage?? |
| ||
If it was added to TImage, then it would needlessly set the rotation angle on all images not rotated at all, so that is probably never going to happen. If you want more control, then you will have to code your own sprite handling functions/types to deal with things like this automatically. |
| ||
Its not needless, its the beginnings of a self-contained class. Every class I write code for usually has three methods; Add(), Update() and Draw(). Keeps everything nice and simple. |
| ||
Perhaps it was not the right way to write it. What I ment was, that it would not be something that would be added into the base code of bmax since you would not always need images rotated, it is better to leave it out of the basic draw code. |
| ||
Easier? How easy do you want it to have? The way BlitzMax handles it is great, and fast. Try rotating with C/C++ and SDL and do this real time :-). Not impossible and not as fast as BlitzMax, but it requires more than 2 lines of code. Nice to see a new user aboard. I just got BlitzMax last week as well. |
| ||
but how much of a slowdown does rotating 0 degrees take? You could just add to the rotation component of rendering the image to check if rotation = 0 then skip the rotation algorithm. |
| ||
but how much of a slowdown does rotating 0 degrees take? Exactly the same as rotating to any other angle. You could just add to the rotation component of rendering the image to check if rotation = 0 then skip the rotation algorithm. I'd wager that its faster to simply force the rotation rather than doing a comparison first. |
| ||
GfK: You are probably right but it would be interesting to test that. |
| ||
Nooooo!!! Please I don't want my projects to run slower in future releases to cater for something that saves someone else a couple of lines of code. If all these kinds of requests were catered for, BlitzMax would be bloated and slow as a snail in treacle. |
| ||
Yeah, and what if you want to draw 50 aliens all at different rotations, using the same image? You can't, because the rotation would be set per-image and you'd need to manually change the rotation 50 times anyway. I think that the way it currently works, is the best way. You need to use custom types anyway to store the position/speed of aliens, so another field for the rotation is no big deal. |
| ||
Yeah make a custom type with tons of other useful fields too. |