I was going to skip by this topic without responding because of your use of "plz" and "lulz"... but then I saw you talking about the NES and got all excited. I was an NES emu dev a while back so for some reason any express of interest in it is a way to endear yourself to me. I'm weird like that.
Anyway let me start by saying that modern graphics have come a long way since NES era. Whereas the NES had a single static playfirled/background and a handful of overlaying sprites... modern graphics don't have any of that. Instead everything is based on rendering polygons. A graphical scene can consist of any number of polygons.
Rendering polygons is not necessarily any more difficult than doing what the NES does (in fact... in some ways it's simpler). It's just different. So any experience with NES graphics will not really help much.
How would I go about loading fx. a .jpg file to the screen |
First of all, you typically wouldn't use a jpg because jpgs are lossy and would look like crap. You'd use a png.
Secondly, you would render a "textured quad". A quad is just 2 triangles placed next to each other to form a rectangle. Each point on the rectangle has a position (where you want it on the screen) and "texture coordinates" (where you want to pull the texture/pixel image data from).
Many graphic libs use the term "Sprite" instead of "Quad", but it basically means the same thing.
As mentioned, each quad has a position. So all you have to do is change its position and redraw the screen.
changing speeds it moves at, |
This has nothing to do with actual graphics, but is rather a logic problem.
Typically the game world is updated several times per second. For a beginner, it's usually easiest to have the update rate the same as the screen refresh rate. So if you want your game to run at 60fps you'd do something like this:
1 2 3 4 5 6
|
while( game_is_running ) // the main game loop
{
get_input_from_user();
update_logic();
redraw_the_screen();
}
|
Every logic update you'd move all your in-game objects at a certain rate (example: 2 pixels per update). To change the speed, you simply adjust that rate (1 pixel per update would move it slower, 3 would move it faster).
how would one typically trigger an event based on position of the picture |
You wouldn't do it based on the picture, you'd do it based on the object. You have to separate "pictures" from "objects". One is graphical and one is logical.
You'd have a logical object which has a position. That object would also own a sprite/quad which it would draw at its current position when the object is drawn. If you move the object, it would also move the picture.
Then in your game logic updates... you can check in-game objects to see if they overlap. And if they do, you can run whatever code to handle that.
This is commonly referred to as "collision detection" and can get pretty complex depending on the type of collision you want. But simple 2D "bounding box" collision is not hard... you just check to see if two rectangles overlap each other.
(oh yea and capturing keypresses ..) |
Any lib that you'd use for this has a way to capture input from keyboard/mouse/gamepads. You often have 2 options:
1) you can poll the realtime state (ie: is a key being held down right at this moment?)
or
2) you can process buffered messages (ie: your game gets sent an "event" or a "message" when a key is pressed and another when a key is released. You can watch those events to keep track of when keys are being pressed).
For games, #1 is usually easier.
So all of that is fine and dandy... but it doesn't answer the real question of how you can write a program that does all of this. The answer to that is
use a library.
I frequently recommend SFML because it's very easy to use and very fast.
http://sfml-dev.org/
Download that, get it set up, and start running through its tutorials. If you have questions you can post them here, as myself and a few others on the boards are pretty familiar with the lib.