Jump to content
  • Advertisement
Sign in to follow this  
velentry

The wall

This topic is 3759 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok i have been reading.....and reading.....and reading how to program i have even had ago at making my own class, but even with all this reading about classes, variables, statements, control flow, data types, i am kind of unsure about implementing it into a game. I mean i can understand about the whole if-then-else statements but from reading i have had no practice of implementing this into a program where the user can interact with it in some way, i might be being thick but it feels like no matter what i read i am just reading and when it comes down to i am actually unsure of how to use it. But i can read the scripts now which i could never do before and looked at blankly i just still feel unsure, i'm finding it hard to explain because at the end of the day i just want to make a simple space invaders game and work from there. I have chosen something like this simply because there will be much less code and if there is anything wrong i can find it and work it out that much easir.....i think what i'm trying to get at is how do i use all this that i have learnt XD Sorry if it seems really thick and all but i feel kinda lost XD Vel

Share this post


Link to post
Share on other sites
Advertisement
You need to learn how to program first before you can make games even as basic as Space Invaders.

If you're absolutely set on learning games right away at least start with basic text based games. Use these simple games to learn programming concepts. Start with guess a number then maybe move up to tic-tac-toe or rock paper scissors. You absolutely can not start from scratch and make even the most simple of games with graphics.

Share this post


Link to post
Share on other sites
I recommend that you do the exercises I posted here. Exercise 5.1/5.2 should bring most of the concepts together.

BTW, I don't know what you are using as your main learning resource, but (from some of your other threads I assume you are using Python) you might want to check this out. Some of the exercises there even involve graphics programming.

Share this post


Link to post
Share on other sites
but for me i'm not sure even how to use the things i have learnt to make a program even i know it sounds really thick but i find just learning commands and things doesn't actually help me make a program there the building blocks thats for sure that i must use but actually using it so it creates something that doesn't just appear in the output box but in its own seperate window if that makes sense

Vel

Share this post


Link to post
Share on other sites
Quote:

but for me i'm not sure even how to use the things i have learnt to make a program even i know it sounds really thick but i find just learning commands and things doesn't actually help me make a program

Unsurprising. You need to practice those things you've learned; you cannot just expect to memorize them and be able to magically apply them correctly when the time comes. It is difficult at first, but that's just the way of it.

Write some simple programs. Get a decent introductory book for whatever language you're using and work through the practice problems they offer. Think of your own simple programs to write to reinforce your skills. You just have to practice.

Share this post


Link to post
Share on other sites
Quote:
Original post by velentry
but for me i'm not sure even how to use the things i have learnt to make a program even i know it sounds really thick but i find just learning commands and things doesn't actually help me make a program there the building blocks thats for sure that i must use but actually using it so it creates something that doesn't just appear in the output box but in its own seperate window if that makes sense

Vel


I find that people who use the term "commands" for describing programming don't really understand how to program. Commands are what you type on the Unix prompt, not what programs are made of. Step back and really spend time learning the language of your choice before you move on to creating windows or graphics.

Share this post


Link to post
Share on other sites
You start with a loop (this will be C++, but translation to Java or whatever should be trivial)


bool done = false;

while(!done){
//update all sprites

//process collisions between sprites

//draw all the sprites

//delay for the next frame
}


A sprite is basically anything that moves around on the screen. It usually has a class like this.

class Sprite{
int xpos, ypos;
int width, heigth;//you may not need these, if your image format stores them
Image spriteImage;//or whatever, depends on graphics lib
Sprite(int x, int y);
void update(); //updates position based velocity, AI, whatever
void draw(Surface screen);
}


Usually, people create a base sprite class and inherit from it for monsters, bullets, player, etc. A sprite is basically an image that moves on the screen.

You'll need to find and learn a graphics API. When you start with that, start by just loading an image and displaying it. Then make it bounce on the screen. Then use a class like the one above to move it, calling it's update() and draw methods, delaying for a little, then doing it again (be sure to clear the screen every time).

heres a sample for a box that bounces around on the screen

class Sprite{
int xpos;
int ypos;
int x_move;
int y_move;
Image spriteImage;
Sprite(int x, int y){
xpos = x;
ypos = y;
x_move = ymove = 4;
spriteImage = LoadImage("boximg.bmp");
}
void update(){
xpos += x_move;//this moves the sprite by x_move pixels
ypos += y_move;//same here
//checking for the edge of the screen is a pain
if(xpos < 0){
xpos = 0;
x_move = -x_move;
}
if(xpos > screenWidth - spriteImage.width){
xpos = screenWidth - spriteImage.width;
x_move = -x_move;
}
//and do it again for ypos, y_move
}
void draw(/*arguments will depend on the library*/){
//whatever it takes to draw spriteImage
//on the screen
//at (xpos, ypos)
}
};

//main is easy now, Sprite does all the work
int main(){
//init graphics
Sprite sprite(0, 0);
bool done = false;
while(!done){
//check user input
if(keyDown(K_SPACE)){
done = true; //this terminates the loop
}
sprite.update()
//clear screen
sprite.draw(/*screen is probably passed here*/);
delay(30);//later this will be calculated on how long processing has taken
}
}


Almost all graphical games follow this basic format. There is a lot of latitude in the details (for example, do while(true){...} and break when finished). Just use your head to expand on it for controlling sprite movements with keys, with mouse, multiple sprite storage, creating new sprites mid-game(that's tricky), collision testing(have fun!), etc. If I haven't made myself clear, feel free to question it.

Share this post


Link to post
Share on other sites
I'm fairly new to programming (i've been doing it for about 2 years now) and i can tell you from experience that you're jumping ahead of yourself. I think it's very exciting to make video games. I'm just getting into it myself (as you might see from my threat history).

I think that first and foremost you need to understand what programming is and apply little by little the concepts that you're learning. Build a very simple program to display "hello world", then add user input to display a string. simple math and guessing games can and will combine user input/output and mathematical operations. That will become the bread and butter of just about any program.

The game i'm working on, is extremely simple, yet with the 2 years experience i have, it's been difficult to write. Don't get frustrated, and don't give up! Games are the most awesome field i can think of working on, but programming is not something you can grasp by just reading.

Good luck and follow the advice of taking little steps at the time =)

Share this post


Link to post
Share on other sites
Quote:
Original post by gregrampage
You need to learn how to program first before you can make games even as basic as Space Invaders.

If you're absolutely set on learning games right away at least start with basic text based games. Use these simple games to learn programming concepts. Start with guess a number then maybe move up to tic-tac-toe or rock paper scissors. You absolutely can not start from scratch and make even the most simple of games with graphics.

Yup basically you are trying to jump the gun to get to the good/fun stuff before you are ready i.e. you really don't know how to program yet in whatever language you picked.
It's kinda like trying to do integrals or differentation in Calculus never having learned Algebra. Yeah you can go through the motions but you really don't have a clue what you are doing or how hard it really is until you solve some integrals for yourself.
What you can do in the meantime while you practice your coding skills though is maybe work on some of the artwork or assets as they call them for your game so you'll be ready when the time comes. Here's an example from the Head First C# Space Invaders Lab you might want to check out.
Also you can write out the pseudocode for the game kinda like what theOcelot already did so that you'll get an idea of what you have to work on before you get to Space Invaders.
Like for instance do you know how to even display an image in your language or where you are going to store your sprites?
Do you know how to clear the screen?
Do you know about double buffering?
etc...

[Edited by - daviangel on July 8, 2008 8:49:24 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!