My next game for Kongregate has been started. It's an "homage" (read: blatant rip-off) of a classic early 80's arcade game. You stay at the center and change gun direction to shoot enemies and incoming bullets. The original was in color, but I wanted to get a b&w vibe for my version.
Anyone want to venture a guess as to the original?
The problem: Bitmap objects (and display objects in general) are always rotated about the (0,0) relative coordinate when the .rotation member is set. This does not allow an object to pivot on the spot, but rather orbit its upper left point.
The solution: specify a coordinate pair to act as the center, perform a matrix rotate transformation on the point to determine where it would be after the rotation and then translate the Bitmap object to account for the difference.
The downside: the x and y location of the rotating bitmap class must be tracked separately from the x and y of the parent Bitmap, as they will be different. Also, an update method must be called to do the offset.
// import the usual suspects import flash.display.Sprite; import flash.display.Bitmap; import flash.events.Event; import openfl.Assets; import flash.Lib; import flash.geom.Matrix; class Main extends Sprite { private var myTest:RotatingBitmap; public function new() { super(); myTest = new RotatingBitmap( Assets.getBitmapData("assets/circle.png") ); myTest.xloc = 400; myTest.yloc = 400; myTest.xcenter=25; myTest.ycenter=25; removeEventListener (Event.ENTER_FRAME, this_onEnterFrame);
} private function this_onEnterFrame(event.Event):Void { myTest.rotation+=15; myTest.update(); } } class RotatingBitmap extends Bitmap { // the intended location, since x and y will be changing public var xloc:Float; public var yloc:Float; // the center x,y of the rotation public var xcenter:Float; public var ycenter:Float; public function new(asset:Dynamic) { // load the asset and add to the stage super(asset); flash.Lib.current.addChild(this); } public function update() { // here's where the magic happens // define the rotation parms var mymatrix:Matrix = new Matrix(); mymatrix.rotate(Math.PI*(this.rotation)/180); // create a point to represent the center var mypoint = new flash.geom.Point(xcenter,ycenter); // transform into a new point var newpoint:flash.geom.Point = mymatrix.transformPoint(mypoint); // move the bitmap to the proper new location this.x = xloc-newpoint.x; this.y = yloc-newpoint.y; }
}
Here is a little example of the default rotation and a rotation set at the (nearly) center of the image.
Despite it being mid/late November, I present my October Challenge submission, D&D. You race through the dungeon and smash into the dragon at the end. Go fast enough and defeat him, or ... not. How did this particular mash-up come about? I started with a concept I had been noodling over for a while, but as the deadline crept closer and closer I jokingly said, "I should just abandon the whole thing and remake Activision Dragster for the 2600." Somewhere in between what I had already done and the game I played as a youngster, Dungeons and Dragsters was born.
It took my coworkers approximately 60 seconds to figure out how to break the driving to get max velocity. Time to rework some of that gearing code.
Happy little trees
-
*Bob Ross*
*28mm*
*"There's nothing wrong with having a tree as a friend."*
*"Everyone sees nature through different eyes."*
The almighty Bob Ross; TV ...
Friday Quick Tip: Gundam Nippers
-
As some of you may have noticed, I've been slowly working my way back into
the hobby pretty heavily. From consuming as much about the lore as I can,
t...
Scenes from the Barrowmaze
-
My daughter and I started playing thru Barrowmaze , (which if you are not
familiar is a classic mega dungeon campaign for old school style RPG play) ...
Blogging about Space Hulk
-
Written by Ron Saikowski, October 10, 2020I've decided to start blogging
and sharing my Space Hulk material. Space Hulk: Boarding Mission Space Hulk
has al...
It's beginning to look a lot like Fishmen...
-
I call this meeting of the Innsmouth Town Hall to order.
Fishfolk are a staple of HP Lovecrafts' The Shadow Over Innsmouth, and they
are mentioned sever...
Lord Carver, BMMD
-
And, what better model to finish up this stretch of photobox fun, than the
Lord Carver himself? I actually painted him a few months before I did that
mass ...
A Malifaux "Stitched Together" Proxy
-
This was indeed originally a dried tea bag, to be used as a proxy figure
for Wyrd Games' Malifaux 32mm tabletop skirmish game.
Stitched Together are es...
Building the Gundam - 08
-
Despite having jumped the gun a bit and assembled the wings... I can't put
them on the Gundam without the harness, so that took priority.
The Gundam has...
A Friendly Shout Out
-
I have to mention an article a friend of mine recently posted over on
Boardgamegeek. It's about his boardgame, Noblemen and discusses it's
beginnings and...
...I'm Back...
-
I'm back. Let's leave it at that. 6th Edition is now out and a new
starter set has been released. It made me want to get back in the saddle
and try so...
Nostalgia Gaming
-
Back in the late 90’s, I regularly met with a gaming group and played Torg.
Torg was a RPG from West End Games. (Which sadly is no longer in business.)...
Update! Works in Progress!
-
Hello painter peoples! Awhile ago I posted a picture of Vanja the fire
queen from Reaper and about how that mini made me love to paint again. Well
I figure...
The Gaunts Make a Field Trip
-
I returned the mostly painted unit of Gaunts for the Hive Fleet to make a
tournament appearance. More painting updates after they return from their
little...