Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

879096 Posts in 32961 Topics- by 24353 Members - Latest Member: kanki

May 23, 2013, 08:54:24 AM
TIGSource ForumsDeveloperTutorialsRequest a Tutorial
Pages: [1] 2 3 ... 33
Print
Author Topic: Request a Tutorial  (Read 89867 times)
Melly
Level 10
*****


This is how being from "da hood" is like, right?


View Profile
« on: October 09, 2008, 04:12:28 AM »

   TUTORIAL REQUESTS GO HERE.



I request a C++ game-making tutorial!

Please? Embarrassed

Alec said he'd do it.
« Last Edit: October 10, 2008, 02:14:45 PM by Derek » Logged

Feel free to disregard the above.
Games: Minus / Action Escape Kitty
diwil
Level 2
**


View Profile WWW
« Reply #1 on: October 09, 2008, 05:52:42 AM »

I'll have enough time in a couple of weeks, and I'll start my YouTube video-tutorial series that'll base on my engine. Everything will be exposed!

And hopefully, by the end of it, people will be able to make a lightning-fast, flexible 2D engine/API/framework.

...Maybe. Lips Sealed
Logged
Hideous
That's cool.
Level 10
*****


holy shit


View Profile WWW Email
« Reply #2 on: October 09, 2008, 07:17:36 AM »

Moosader has a cool Allegro platform tutorial on YouTube. Except her map editor breaks for a lot of people, apparently.
Logged

In a world where ugly babies rule supreme...
xerus
Vice President of Marketing, Romeo Pie Software
Level 10
*


kpulv

Storm+X+MH
View Profile WWW
« Reply #3 on: October 09, 2008, 07:30:22 AM »

Yes.  I've spent months trying to figure out the best way to make an engine properly.  Weeeeee!
Logged

FARTRON
Level 4
****


the last man in space


View Profile WWW
« Reply #4 on: October 09, 2008, 07:33:10 AM »

I'd definitely like to see more tutorials on tile engines and such, whatever the language.
Logged

Everything that was once directly lived has receded into a representation. - debord
increpare
Guest
« Reply #5 on: October 09, 2008, 07:36:34 AM »

I've been meaning to start a game-loop thread for a while...(not specifically c++, though).

(my c++ isn't confident or neat enough to give a tutorial in).

Can you already do games stuff in plain ol' C melly?

Fartron: what sort of tile engines are you thinking about?  There are already plenty of tile engine tutorials on the web, though; someone's probably already written something to suit your needs.
Logged
Hideous
That's cool.
Level 10
*****


holy shit


View Profile WWW Email
« Reply #6 on: October 09, 2008, 07:46:31 AM »

I'd like to see a tetris tutorial in c++, actually. Thinking about how the rotation would work has had my brain stumped for a long time.
Logged

In a world where ugly babies rule supreme...
Cymon
Level 9
****


Computer Kid


View Profile WWW Email
« Reply #7 on: October 09, 2008, 07:52:44 AM »

I hate requests like then when I'm contemplating the same thing.

And Hideous. I don't know if it would help you, but you can always peek at my code for alleytris, tho the rotation aspect ended up being a bit obfuscated.
Logged

Cymon's Games, free source code, tutorials, and a new game every week!
Follow me on twitter
Hideous
That's cool.
Level 10
*****


holy shit


View Profile WWW Email
« Reply #8 on: October 09, 2008, 07:58:48 AM »

I actually did look at alleytris before, but didn't really learn anything from it.
Logged

In a world where ugly babies rule supreme...
FARTRON
Level 4
****


the last man in space


View Profile WWW
« Reply #9 on: October 09, 2008, 08:52:12 AM »

Fartron: what sort of tile engines are you thinking about?  There are already plenty of tile engine tutorials on the web, though; someone's probably already written something to suit your needs.

There aren't a lot of good ones. I guess I'm picturing something on the general side, the ins-and-outs of designing engines. I want to have a better idea of how to make them from scratch in various languages, and with various goals (roguelike, platformer, topdown shooter, etc) which I don't get from a lot of the copy-paste tutorials I've seen.
Logged

Everything that was once directly lived has receded into a representation. - debord
muku
Level 10
*****



View Profile WWW
« Reply #10 on: October 09, 2008, 08:55:14 AM »

Rotation for Tetris pieces is pretty easy. If you have the coordinates of each each block in the piece in a list, you just go through the list and transform every pair of coordinates like:

(x, y) -> (-y, x)

That corresponds to a 90 degree rotation.

That's the gist of it, at least.
Logged

The Cosyne Synthesis Engine - realtime music synthesis for games
Melly
Level 10
*****


This is how being from "da hood" is like, right?


View Profile
« Reply #11 on: October 09, 2008, 01:39:00 PM »

Can you already do games stuff in plain ol' C melly?

Nope.
Logged

Feel free to disregard the above.
Games: Minus / Action Escape Kitty
Cymon
Level 9
****


Computer Kid


View Profile WWW Email
« Reply #12 on: October 09, 2008, 06:16:07 PM »

I actually did look at alleytris before, but didn't really learn anything from it.
Can't blame you for that.
Rotation for Tetris pieces is pretty easy. If you have the coordinates of each each block in the piece in a list, you just go through the list and transform every pair of coordinates like:

(x, y) -> (-y, x)

That corresponds to a 90 degree rotation.

That's the gist of it, at least.
It's not quite that easy. Or at least if it is I went the long way on Alleytris. The problem with that idea is it rotates around a center point at the corner.

For the panda of it I'll try to recreate the thought process that ended in the rx function in alleytris.

What you need to do is adjust how you're reading the data, so when you write it the normal way it appears rotated. In otherwords for a 4x4 block 90o clockwise rotation means you start in the lower left corner and read bottom to top. For 180o start in the lower right and read right to left, bottom to top. For 270o start in the upper left and read top to bottom, right to left.

You following so far?

So when I was writing alleytris I started doing some drawings and ended up with this table and stared at it until I got the last line:
X,Y90180270
(0,0)(0,4)(4,4)(4,0)
(1,0)(0,3)(3,4)(4,1)
(1,1)(1,3)(3,3)(3,1)
(4,4)(4,0)(0,0)(4,0)
(x,y)(y,4-x)(4-x,4-y)(4-y,x)

So I figured I needed 2 rotations functions which would take the rotation given (which by then I had simplified to 0,1,2,and 3) and the x, y coordinate and return either the x or y. At first I used a case statement, and that's when I noticed the similarity between rx (for rotation x) and ry (for rotation y), that was that ry(rot,x,y) was the same as rx(rot+1,x,y). So deleted ry (which in retrospect I should have kept and just rewritten ry to call rx) and changed all calls to ry to calls to rx.

Then someone on the cprogramming forums pointed out a way to do away with the case statement and I ended up with the current version of rx :
Code:
int rx (int r, int y, int x) { /* Used for piece rotation. */
  int n;

  n = (r % 2 ? y : x);
  if(r / 2) n = 3 - n;
  return n;
}

clip() and drawpiece() use rx to read the data rotated as it draws the piece.

Now you know why alleytris was not as instructive. It was the tail end of a long thought process which works, but doesn't educate much.

So even if alleytris wasn't informative I hope this was.
Logged

Cymon's Games, free source code, tutorials, and a new game every week!
Follow me on twitter
muku
Level 10
*****



View Profile WWW
« Reply #13 on: October 09, 2008, 06:23:44 PM »

I actually did look at alleytris before, but didn't really learn anything from it.
Can't blame you for that.
Rotation for Tetris pieces is pretty easy. If you have the coordinates of each each block in the piece in a list, you just go through the list and transform every pair of coordinates like:

(x, y) -> (-y, x)

That corresponds to a 90 degree rotation.

That's the gist of it, at least.
It's not quite that easy. Or at least if it is I went the long way on Alleytris. The problem with that idea is it rotates around a center point at the corner.

It rotates the piece around (0,0), so if you lay out your pieces so that they have their center at (or around) (0,0), you should be fine. Alternatively, rotating around an arbitrary point is as simple as translating, applying above rotation formula, and translating back.

Also, if you don't want to calculate the formulae for rotating by 180 and 270 degrees, you can simply call your 90 degree rotation function multiple times.
Logged

The Cosyne Synthesis Engine - realtime music synthesis for games
Ivan
Owl Country
Level 10
*


alright, let's see what we can see

Valaam0
View Profile
« Reply #14 on: October 09, 2008, 06:58:03 PM »

http://code.google.com/p/tetryx/source/browse/trunk/src/tetris_game.c

(Really old) source for my old opengl tetris game. It's pure C, and not C++, but might be helpful.
Logged

http://polycode.org/ - Free, cross-platform, open-source engine.
Pages: [1] 2 3 ... 33
Print
Jump to:  

Theme orange-lt created by panic