Gun Model


Created a gun model in Blender.  The gun was created using three cubes, which have three different textures.  I deleted half of the cube vertices to make a plane, and I moved the remaining vertices to trace around the gun image that I added as the background image.  Additional vertices were added to the plane by selecting two vertices and pressing “W”.  That will subdivide the line, adding a new vertex.  After I had the outline, I extruded the points out in the y direction to give the model depth.  Since this will be used for a small image, I wasn’t concerned with making the depth very detailed.  It just needed to be simple enough to make the gun not appear to be flat like a piece of paper.  For now, the textures are just using different diffuse coloring, which are dark green, light green, and white for the trigger.  I would like to make it so that I can programmtically change these colors to make different weapons, without generating new weapon sprites.  Just like with the player and socket sprites, I added an armature.  In this case, the armature looks like a “T”.  I turned on automatic keyframing (red record button), set the frames to 20, and rotated the model 90 degrees for each 5 frames.  Then I exported the animation to image files, cropped and shrunk those images with Gimp and exported those into new PNG images.  Finally, I added the images as content objects in the Blasting Bits project.  I updated the code to display a CollectibleWeapon to use these image textures instead of the default image.  As with the socket images, I had to set the maximum number of frames to 20, since the default is 30 frames.


When I tried running the game, the gun sprites would display and rotate, but it seemed to rotate extremely quickly.  Therefore, I updated the Collectible class with two new instance variables which add a frame delay and maximum frame delay.  The frame delay is private, and gets decremented on each update.  When the frame delay reaches zero, then the animation frame is incremented and the frame delay is set to the maximum frame delay.  The maximum frame delay variable is protected, since subclasses will need to set the delay value for its collectible type.  For the CollectibleWeapon, I set the maximum frame dealy to 2, so that there are two frames of delay before the next image is displayed.  This makes the gun rotate much more slowly and looks better.


One Reply to “Gun Model”

Comments are closed.