Omnimaga
General Discussion => Technology and Development => Computer Programming => Topic started by: runeazn on February 25, 2012, 10:24:00 am
-
I still dont get how you can make games with coding after getting a little taste of coding language python :P
-
Basically, what most games do is repeat one or more loops to get everything done (with routines and stuff).
btw you better make your questions more closed. (like "how do i code feature x as seen in game y")
-
how the heck can a loop show something?
ok itll loop the draw comment everytime.
but ho wdoes it pickup if lets say a picture bumps onto another picture, and this results into a movement of the other picture?
-
In a modern programming language, you have a display routine that draws stuff to the screen. (for example called void draw{ } ). This routine is called every frame.
-
display routine?
-
Yeah, its a routine that does display stuff. Like displaying pictures or text.
-
but how does it detect that a pictures collides with another picture and that the other picture needs to move.
lets say, user, bumps against a box and box needs to move.
what i think you do:
do you code that if that picture is within this area of this picture than this will happen?
is this true?
and whats maa more efficient way to do this?
-
It does not. It's got coordinates of both things and checks if they are close enough if so, move the box.
-
aha ok,
how do you store the said "picture"
in a variable?
and how can it read the said picture? I dont think it cant read jpg or something can it?
-
All modern programming languages can read jpg. (png is used more)
And they "store" those pictures by telling the program that "this file is a picture"
-
so it calls a img everytime ok.
how does it get continuously the "keys" of movement?
all i have worked up till now is the input command but it will wait till something is inputted and after that it would continue.
This would be no plausible solution to use right?
how do we do it now?
-
Programs take keycodes. Every key on a keyboard has a different signal. The program reads the signal every loop and just continues when there's no key pressed.
-
All games come down to the basic game life cycle. I recommend watching this video (http://create.msdn.com/en-US/education/tutorial/2dgame/design). Though it's for XNA (.NET) and not Python, it gives a pretty detailed overview and explanation of the life cycle.
-
lets say pong, how do you let the ball move from direction?
or better said how do you move a object without user input.
-
Do (ballpos)+1->ballpos every loop.
-
Did you watch the video? To do what you asked, you would just update everything that needs to be updated when your update method is called. Here's some pseudocode to demonstrate what I mean:
update:
move ball based on travelling direction
if ball collides with wall or paddle
method to make ball bounce off of surface
if ball has passed some paddle
add point to winner
reset ball location
if user presses a key we will use (i.e. Up, Down, W or S)
update player's paddle location
update AI
draw:
clear background
draw scores
draw walls
draw ball
Basically after each draw method is done, the update method will be called, and when each update method is done the draw method will be called.
-
thats no explanation D:
-
Do you know what you should do? get a 84+ and learn programming in BASIC and then in Axe. I'm not rude, but that REALLY helps A LOT. In fact, w/o my 84 i would never have been programming stuffs.
-
OP, if you don't have much experience, I don't recommend you to try out coding games just yet. However, in the near future, try pygame, it's great for making games with Python. I don't recommend C# or XNA because it's not cross-platform :)
-
If you're doing pong, you're going to want four variables for the ball: x, y, x velocity, and y velocity. To start the ball going to the lower right, we'd set the x vel. and y vel. both to 1. Then we'd increase x by x vel. and y by y vel. each loop iteration to make the ball move. To flip the direction of movement do
velocity variable *= -1
-
how do you make the bal move?
yes let it draw every frame but how do we let it add the x and y coordinates?
as the spot where the ball hits the uhh stick it will decide the movement the ball will make.
-
You define more variables. Just like 1->x and stuff. ITS EASY BRO.
Look up a python tutorial for dummys.
-
I'm going to go with aeTIos on this and say read a Python tutorial. A lot of games do basic math and updating, which are covered in tutorials.
-
My experience:
90% of programming is saying "calculate x+24c+6-f*2(55y)" and stuff. Not a joke.
-
I still dont get how you can make games with coding after getting a little taste of coding language python :P
Eck, this question sure is vague...
A nice analogy might be "I still don't understand how they predict the weather after using an iPhone app." :P
Here's a high level overview of how games work though:
- The user executes the program by running it in some fashion
- The program initializes itself (allocates memory, checks to make sure the levels are present, sets constants, etc...)
- The program then begins executing. It will often go into a menu around this point, which will allow the user to select what level they want to play and other stuff.
- The program loads all the data necessary then begins executing the game code.
- The program enters what is referred to as a "big honkin' loop." This loop is where the entire game happens.
- Inside the "big honkin' loop, many things occur. The first is sometimes that the world is generated and rendered onscreen.[/li
- Then all of the stuff the player will interact with is rendered (such as enemies)
- The player's controls are checked for inputs. If there are inputs, the world is adjusted accordingly. Otherwise, the game continues as if nothing happened (because that's exactly what happened).
- When the player tells the game to quit/exit, the game breaks out of the loop and shuts down.
-
My experience:
90% of programming is saying "calculate x+24c+6-f*2(55y)" and stuff. Not a joke.
Yes games also have a lot of complex math, but even games like Crysis have simple math in them.
I still dont get how you can make games with coding after getting a little taste of coding language python :P
Eck, this question sure is vague...
A nice analogy might be "I still don't understand how they predict the weather after using an iPhone app." :P
^ This. One does not simply know all the programming after a "little taste."
-
Games like Crysis are largely an exercise in "How simple can we make the code to do this?" I've used some of the published algorithms from games including Crysis before and it's amazing just how simple some of the things are. In crysis II, for example, a lot of the stuff they use are best described as hacks. Were you a bit disappointed when you saw that Deep Thought's fruit ninja used a bunch of static sprites to make the fruit "rotate?" Turns out, that's what Crysis does for some of its plant shading. Complete rubbish as far as true realism goes, but who can argue with the results? Being able to simplify things tremendously like that is part of the Art of Game Programming. It's also a very advanced topic in places :P
EDIT: I love Deep Thought's way of rotating the fruit, if it's not clear. Great job, Hal!
-
Personally I wasn't surprised when I saw it. That's exactly the way I would've done something like that. In fact, it is the way I do things. For animations I just use a bunch of sprites and loop them together based on the game's time. Plus I'd imagine that's the fastest way to do that kind of thing, especially with shading and in large games like Crysis. I always love finding out how things that seem complex are actually really simple. It all comes down to whether or not you're over-thinking something or not.
-
I know quite a bit of Python already: all of the basic built-in functions, how to do GUIs, and how to connect to the internet with it. However, I still don't have enough knowledge to make a decent game. It takes quite a lot of programming knowledge to make good graphical games.
-
The program enters what is referred to as a "big honkin' loop." This loop is where the entire game happens.
Lol, people call it the big honkin' loop? :P
-
little taste as completed one tutorial on python :) http://www.khanacademy.org/
the tutorial wasnt long though, i followed the tutorial on khan academy
, and now i am following the tutorial called "LearnPythonTheHardway" on http://learnpythonthehardway.org haha
any other good tutorials?
-
I'm learning Python with this tutorial (http://www.swaroopch.com/notes/Python).
-
Not sure if it's been mentioned yet but IMO the best way to display graphics using Python is Pygame (pygame.org) and the best way to package and distribute is as a .EXE file is Py2exe (py2exe.org)
-
Basically games are made up with a main loop. What happens is this:
1. Game starts
2. All the windows are set up and so on.
3. You enter the main game loop
4. The loop continually does the following:
a. Get input, and process it
b. All game logic (i.e. move sprites, updates positions, and checks collisions.)
c. Update the screen
d. Goto [a].
5. Thats it :)
Here is some Pseudo-code of the main loop.
while(running){
while(SDL_PollEvent(&Event)) // Get key-presses and process them
currentState->Event(&Event);
currentState->Loop(); // Check gamelogic
currentState->Render(); // Update screen
}
-
Basically games are made up with a main loop. What happens is this:
1. Game starts
2. All the windows are set up and so on.
3. You enter the main game loop
4. The loop continually does the following:
a. Get input, and process it
b. All game logic (i.e. move sprites, updates positions, and checks collisions.)
c. Update the screen
d. Goto [a].
5. Thats it :)
Here is some Pseudo-code of the main loop.
while(running){
while(SDL_PollEvent(&Event)) // Get key-presses and process them
currentState->Event(&Event);
currentState->Loop(); // Check gamelogic
currentState->Render(); // Update screen
}
What a necropost, nice!
-
and isnt that C/++ code...
But good summary of how making games works
-
Thanks, and yes it's C++ code from my project, but for all purposes it's Pseudocode, as long it illustrates the concept.
-
Something I've always found with games, is that you can split them into three main parts. Input, processing, output.
For something like having a picture collide with another, you'd do as what was said earlier and store the coordinate data and use them during processing. You'd store the picture in an object and you'd use a reference to that object, basically variables. What that object is depends on the library you use or a class you write yourself.
Edit: Using tapatalk, didn't realize this was an old thread :P My apologies.