drawing & animation
using the win32 gdi #1
a big 'thank you' goes out to all the people reading and reporting the bugs in the previous version of this tutorial. please provide comments, questions, bug reports etc. at the vbexplorer.com forums in the graphics & game programming section.
graphics
one of the most important aspects of any game are the graphics. graphics provide a visual interface for game play and more importantly, the means to explore exciting and fantastical virtual worlds. this means that cool graphics and smooth animation are key issues you will need to consider if you hope to create the right atmosphere and environment for enjoyable game play. while certainly not the only issues, they are two of the main factors that will affect the popularity and possible commercial success of your game.
download sample programs here.
graphics programming in the world of windows and gdi is largely based on bitmaps. a bitmap is a structure, generally composed of a multitude of small dots, known as pixels, each being of a specific color. a bitmap file, with the extension bmp, is the file format that will be used throughout this book to store graphical elements. we will go a bit more into what a bitmap actually is and discuss various methods to manipulate them from both a programming and a design perspective.
there are many ways to display a bitmap in visual basic. let's look a one of the simplest which is the picture property.
a standard form has a picture property, which can be used to display a bitmap. the other two controls most often used for presenting graphics in visual basic, are the image control and the picture box. of these two, the picture box is the control you are likely to use most often as a game programmer.
the main reason for using the picturebox control, instead of the image control, is that it has a hdc property. this hdc property is used when we draw bitmaps to and from our drawing areas using an api function, which we will discuss next.
drawing a bitmap
most games with graphics must be able to rapidly draw several graphics repeatedly from a source context onto the destination, which would be the actual gaming area. the need for this is quite obvious, since few games are compromised of a single graphic file with no animation. certainly none that would interest a famous future game developer like you. so in order to make our games more interesting we need a way to draw a bitmap (or parts of it) from one place (the source), to another place (the destination).