Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Do Mär 28, 2024 14:49

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 18 Beiträge ]  Gehe zu Seite 1, 2  Nächste
Autor Nachricht
 Betreff des Beitrags: Slot game
BeitragVerfasst: Di Mär 23, 2010 14:02 
Offline
DGL Member

Registriert: Di Mär 23, 2010 13:40
Beiträge: 14
Hello,

First thank you for awesome tutorials for delphi and opengl.

I want to make some simple 2D slot game, but I am stuck about how to scroll reels.
I got two ideas how to do it, OR if anyone have any better idea, I would gladly hear it.
1. using SDL and rectangles, and increse y (simple way, but dont know how smooth it would be)
2. opengl with cone, attaching texture to cone scrolling (a bit difficult) but how would detect wins?

best regards,
Vladimir


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Slot game
BeitragVerfasst: Di Mär 23, 2010 15:04 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 29, 2005 12:28
Beiträge: 2249
Wohnort: Düsseldorf
Programmiersprache: C++, C#, Java
When using OpenGL the easiest way would be a textured Quad. Set texture wrap mode to GL_REPEAT, then you can rotate each wheel simply by setting texture coordinates. It's possible SDL is also able to do this, I'm not familiar with SDL.

I don't see how a cone would help here. However, you could use a textured cylinder. When rendering in 3D this would cause some nice perspective effects: The slot-wheel would really look like a wheel. Also there would be no need to change the texture coords, you could simply rotate the wheel using glRotate.

_________________
Yeah! :mrgreen:


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Slot game
BeitragVerfasst: Mi Mär 24, 2010 00:29 
Offline
DGL Member

Registriert: Di Mär 23, 2010 13:40
Beiträge: 14
Coolcat hat geschrieben:
When using OpenGL the easiest way would be a textured Quad. Set texture wrap mode to GL_REPEAT, then you can rotate each wheel simply by setting texture coordinates. It's possible SDL is also able to do this, I'm not familiar with SDL.



I don't see how a cone would help here. However, you could use a textured cylinder. When rendering in 3D this would cause some nice perspective effects: The slot-wheel would really look like a wheel. Also there would be no need to change the texture coords, you could simply rotate the wheel using glRotate.


First thanks for fast reply
Ok for Quad, but then i would be limited to 4 sides / different symbols?
with SDL would be much simpler since it uses rectangles to draw, but I would like to try with Opengl since i would also need to add motion blur effect for better look. (need to explore how)

sorry, i mean cylinder, but then i dont understand how many symbols i could max "glue" to cylinder, for example, i found this sample for a test http://img651.imageshack.us/i/reelstexture.png/ so lets say i need first 10 vertical symbols in first reel, how big cylinder i would need to make? and i would need to make 5 cylinders so i could roll each cylinder independantly?


many thanks,
Vladimir


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Slot game
BeitragVerfasst: Mi Mär 24, 2010 10:19 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 29, 2005 12:28
Beiträge: 2249
Wohnort: Düsseldorf
Programmiersprache: C++, C#, Java
Zitat:
Ok for Quad, but then i would be limited to 4 sides / different symbols?

No. Using the Quad you can display a small window of your symbol texture. This has the size of one single symbol and scrolls over the texture. The number of symbols is only limited by the texture size.
This is basically the same as when drawing an image using SDL. The only difference is that in the OpenGL case the trick is done by graphics hardware, while SDL does use the CPU. However, performance is not a problem here since you only need a few wheels.

Zitat:
but I would like to try with Opengl since i would also need to add motion blur effect for better look.

Just render each wheel multiply times with slightly different positions in rotation direction. All rendered images are combined together with additive blending, which does result in some kind of average image.

Code:
glEnable(GL_BLEND);
glBlendColor(factor,factor,factor,factor);
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE);
// render image
glDisable(GL_BLEND);


In a simple case factor is just "1 / image count". However, I recommend to use a Gauss function for factor, because it does not produce artifacts. For details on Gauss functions take a look on this shader article:
http://wiki.delphigl.com/index.php/shad ... schreibung
Don't bother what a "shader" is, just take a look on the image and formula.

Zitat:
i dont understand how many symbols i could max "glue" to cylinder,

Just wrap the texture around the cylinder. Just imagine a real cylinder: You can wrap a piece of paper of length 2*PI*radius around it. The number of symbols is again only limited by the texture size. However, if the texture gets larger, the display size of each symbol will be smaller, since you will have to scale the texture to 2*PI*radius height.

Zitat:
how big cylinder i would need to make?

As big as a real cylinder would be. If you need 10 symbols, each symbol would get 360/10 = 36 degree on the wheel. So you need to scale the wheel so that a 36 degree window does match your favored size.

Zitat:
and i would need to make 5 cylinders so i could roll each cylinder independantly?

No, you could use the same cylinder rendered multiple times with different symbol textures and positions.

_________________
Yeah! :mrgreen:


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Slot game
BeitragVerfasst: Mi Mär 24, 2010 17:49 
Offline
DGL Member

Registriert: Di Mär 23, 2010 13:40
Beiträge: 14
Coolcat hat geschrieben:
Zitat:
Ok for Quad, but then i would be limited to 4 sides / different symbols?

No. Using the Quad you can display a small window of your symbol texture. This has the size of one single symbol and scrolls over the texture. The number of symbols is only limited by the texture size.
This is basically the same as when drawing an image using SDL. The only difference is that in the OpenGL case the trick is done by graphics hardware, while SDL does use the CPU. However, performance is not a problem here since you only need a few wheels.

Zitat:
but I would like to try with Opengl since i would also need to add motion blur effect for better look.

Just render each wheel multiply times with slightly different positions in rotation direction. All rendered images are combined together with additive blending, which does result in some kind of average image.

Code:
glEnable(GL_BLEND);
glBlendColor(factor,factor,factor,factor);
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE);
// render image
glDisable(GL_BLEND);


In a simple case factor is just "1 / image count". However, I recommend to use a Gauss function for factor, because it does not produce artifacts. For details on Gauss functions take a look on this shader article:
http://wiki.delphigl.com/index.php/shad ... schreibung
Don't bother what a "shader" is, just take a look on the image and formula.

Zitat:
i dont understand how many symbols i could max "glue" to cylinder,

Just wrap the texture around the cylinder. Just imagine a real cylinder: You can wrap a piece of paper of length 2*PI*radius around it. The number of symbols is again only limited by the texture size. However, if the texture gets larger, the display size of each symbol will be smaller, since you will have to scale the texture to 2*PI*radius height.

Zitat:
how big cylinder i would need to make?

As big as a real cylinder would be. If you need 10 symbols, each symbol would get 360/10 = 36 degree on the wheel. So you need to scale the wheel so that a 36 degree window does match your favored size.

Zitat:
and i would need to make 5 cylinders so i could roll each cylinder independantly?

No, you could use the same cylinder rendered multiple times with different symbol textures and positions.


thanks you for your helpful advices, but seems that i will have to read some more about opengl, since i cant draw cylinder in front of view port ;-)
--
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glLoadIdentity;
glTranslatef(15.,0.0,-20.0);


glPushMatrix;
glrotatef(cylinderrot,0,0,1);
glTranslatef(0.0, 0.0, -30.0 );
gluCylinder( quadric, 10.0, 10.0, 25.0, 32, 32 );
glPopMatrix;
SDL_GL_Swapbuffers;

cylinderrot:=cylinderrot+0.05;
--
it is always around me, but not in front as it should


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Slot game
BeitragVerfasst: Mi Mär 24, 2010 19:10 
Offline
Guitar Hero
Benutzeravatar

Registriert: Do Sep 25, 2003 15:56
Beiträge: 7804
Wohnort: Sachsen - ERZ / C
Programmiersprache: Java (, Pascal)
Have a look at the pictures in "Tutorial_Matrix2". That may help.

_________________
Blog: kevin-fleischer.de und fbaingermany.com


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Slot game
BeitragVerfasst: Mi Mär 24, 2010 20:20 
Offline
DGL Member

Registriert: Di Mär 23, 2010 13:40
Beiträge: 14
Flash hat geschrieben:
Have a look at the pictures in "Tutorial_Matrix2". That may help.


thanks but something is wrong, Or cylinder is created around some other axis
because i did one example with cube and rotate around x axis like this
glTranslatef(0,0,-5);
glrotate(xrotate,1.0,0,0.0)
draw cube here

so what i am doing wrong with cylinder?


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Slot game
BeitragVerfasst: Do Mär 25, 2010 00:16 
Offline
Guitar Hero
Benutzeravatar

Registriert: Do Sep 25, 2003 15:56
Beiträge: 7804
Wohnort: Sachsen - ERZ / C
Programmiersprache: Java (, Pascal)
As Far as I remember, the cylinder is oriented along the Z-axis.
So you have to add an additional rotation, to see the correct side of the cylinder.

_________________
Blog: kevin-fleischer.de und fbaingermany.com


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Slot game
BeitragVerfasst: Do Mär 25, 2010 09:40 
Offline
DGL Member

Registriert: Di Mär 23, 2010 13:40
Beiträge: 14
Flash hat geschrieben:
As Far as I remember, the cylinder is oriented along the Z-axis.
So you have to add an additional rotation, to see the correct side of the cylinder.


you were right, i had to rotate additionaly like:
gltranslatef(0,0,-25);

glpushmatrix;
glrotatef(cyl_rot,1,0,0); // rotate around x axis
gltranslate(-1.5,0,0); // go to center of cylinder
glrotatef(90,0,1,0); rotate for 90 degrees
glucylinder(quadric,5.0,5.0,5.0,50,5);
glpopmatrix;

and now it rotates in front of "camera"


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Slot game
BeitragVerfasst: Do Mär 25, 2010 09:47 
Offline
DGL Member

Registriert: Di Mär 23, 2010 13:40
Beiträge: 14
Coolcat hat geschrieben:
Zitat:
Ok for Quad, but then i would be limited to 4 sides / different symbols?

No. Using the Quad you can display a small window of your symbol texture. This has the size of one single symbol and scrolls over the texture. The number of symbols is only limited by the texture size.
This is basically the same as when drawing an image using SDL. The only difference is that in the OpenGL case the trick is done by graphics hardware, while SDL does use the CPU. However, performance is not a problem here since you only need a few wheels.

Zitat:
but I would like to try with Opengl since i would also need to add motion blur effect for better look.

Just render each wheel multiply times with slightly different positions in rotation direction. All rendered images are combined together with additive blending, which does result in some kind of average image.

Code:
glEnable(GL_BLEND);
glBlendColor(factor,factor,factor,factor);
glBlendFunc(GL_CONSTANT_COLOR, GL_ONE);
// render image
glDisable(GL_BLEND);


In a simple case factor is just "1 / image count". However, I recommend to use a Gauss function for factor, because it does not produce artifacts. For details on Gauss functions take a look on this shader article:
http://wiki.delphigl.com/index.php/shad ... schreibung
Don't bother what a "shader" is, just take a look on the image and formula.

Zitat:
i dont understand how many symbols i could max "glue" to cylinder,

Just wrap the texture around the cylinder. Just imagine a real cylinder: You can wrap a piece of paper of length 2*PI*radius around it. The number of symbols is again only limited by the texture size. However, if the texture gets larger, the display size of each symbol will be smaller, since you will have to scale the texture to 2*PI*radius height.

Zitat:
how big cylinder i would need to make?

As big as a real cylinder would be. If you need 10 symbols, each symbol would get 360/10 = 36 degree on the wheel. So you need to scale the wheel so that a 36 degree window does match your favored size.

Zitat:
and i would need to make 5 cylinders so i could roll each cylinder independantly?

No, you could use the same cylinder rendered multiple times with different symbol textures and positions.


many thanks again coolcat for your advices.
for now i draw a cylinder and rotate it , but i have some questions about textures
since i want to use this example http://img651.imageshack.us/i/reelstexture.png/
is it possible to load each symbol as sprite? (in SDL it is very simple using rectangles) or even combination of SDL rectangle and OpenGL textures?
and how to apply each sprite(symbol) to one cylinder side? (byt coordinates or?)
the thing I dont understand is 3 symbols must be visible at one time (for example first 3 vertical from picture above)
so I wanted to load like first 4 x 3 vertical symbols and wrap around cylinder and rotate (and alter try to do add that blue effect using gauss function you suggested)


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Slot game
BeitragVerfasst: Fr Mär 26, 2010 09:59 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 29, 2005 12:28
Beiträge: 2249
Wohnort: Düsseldorf
Programmiersprache: C++, C#, Java
(Please do not quote full posts. It is much more readable if you just quote the relevant part. Thanks.)

Zitat:
and how to apply each sprite(symbol) to one cylinder side? (byt coordinates or?)

The easiest way would be to handle all symbols at once: Use one full column of your image as texture.
First you have to active texture coordinates for your Cylinder:
Code:
gluQuadricTexture(quadric, GL_TRUE);
glucylinder(quadric,5.0,5.0,5.0,50,5);

Now just setup and bind your texture, OpenGL will wrap it automatically around the cylinder. It's possible that you will have to rotate your image by 90 degree.

_________________
Yeah! :mrgreen:


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Slot game
BeitragVerfasst: Fr Mär 26, 2010 11:48 
Offline
DGL Member

Registriert: Di Mär 23, 2010 13:40
Beiträge: 14
Zitat:
and how to apply each sprite(symbol) to one cylinder side? (byt coordinates or?)

The easiest way would be to handle all symbols at once: Use one full column of your image as texture.
First you have to active texture coordinates for your Cylinder:
Code:
gluQuadricTexture(quadric, GL_TRUE);
glucylinder(quadric,5.0,5.0,5.0,50,5);

Now just setup and bind your texture, OpenGL will wrap it automatically around the cylinder. It's possible that you will have to rotate your image by 90 degree.[/quote]

1. well i just finished playing with loading big texture file and applying different symbols to different side of the quad (for test only using gltexcoord2f)

2. now, about texturing cylinder, i want to have 5 reels which i can roll indenpendently (since it will have different symbols/position), but you said that i can do it with just one cylinder? for example, first reel scrolls with symbols, then small pause second reel scrolls etc..


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Slot game
BeitragVerfasst: Fr Mär 26, 2010 12:22 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 29, 2005 12:28
Beiträge: 2249
Wohnort: Düsseldorf
Programmiersprache: C++, C#, Java
Zitat:
but you said that i can do it with just one cylinder?

You could either use 5 different textures and bind the correct texture each time when you draw the cylinder.

The other way would be using one single big texture and select the correct column using a texture matrix:
Let n be the number of columns and i the column you want do select starting with zero. Texture coordinates (s,t) run always from 0 to 1. To select a column you need to map t-coordinates i/n ... (i+1)/n to the full size 0 ... 1. This can be done using a Texture matrix. Each texture coordinate is multiplied by this matrix. The mapping you need to do is:
Code:
s := s; // don't change s
t := (t / n) + (i/n);

In OpenGL this does look like this:
Code:
glMatrixMode(GL_TEXTURE);
glScalef(1,1/n,1);
glTranslatef(0,i/n,0);
glMatrixMode(GL_MODELVIEW);


It's possible that you have to swap glScale and glTranslate.

_________________
Yeah! :mrgreen:


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Slot game
BeitragVerfasst: Fr Mär 26, 2010 14:17 
Offline
DGL Member

Registriert: Di Mär 23, 2010 13:40
Beiträge: 14
Coolcat hat geschrieben:
Zitat:
but you said that i can do it with just one cylinder?

You could either use 5 different textures and bind the correct texture each time when you draw the cylinder.

The other way would be using one single big texture and select the correct column using a texture matrix:
Let n be the number of columns and i the column you want do select starting with zero. Texture coordinates (s,t) run always from 0 to 1. To select a column you need to map t-coordinates i/n ... (i+1)/n to the full size 0 ... 1. This can be done using a Texture matrix. Each texture coordinate is multiplied by this matrix. The mapping you need to do is:
Code:
s := s; // don't change s
t := (t / n) + (i/n);

In OpenGL this does look like this:
Code:
glMatrixMode(GL_TEXTURE);
glScalef(1,1/n,1);
glTranslatef(0,i/n,0);
glMatrixMode(GL_MODELVIEW);


It's possible that you have to swap glScale and glTranslate.


making loop and loading texture symbol in array is not a problem.
but i dont see how i can bind those texture symbols like this
cylinder
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

only 3x5 symbols are visible at once
and roll first reel(1-1-1) and then second (2-2-2) separately?


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Slot game
BeitragVerfasst: Fr Apr 30, 2010 14:59 
Offline
DGL Member

Registriert: Di Mär 23, 2010 13:40
Beiträge: 14
hello again
sorry for late reply, was busy with real life,
i investigate a bit ith cylinders and textures about slot game and i have few questions.

1. about background? to create one big quad and put texture to it? is that good approach?

2. so far i created 5 cylinders and rotate them nicely, but about texture, i need to wrap like 20-30 elements (one big bmp, with elements sorted verticaly) and still need to play with blending to create blur by gaussian formula

3. what do you suggest for font? using rasters?

many thanks,
Vladimir


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 18 Beiträge ]  Gehe zu Seite 1, 2  Nächste
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 4 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.061s | 17 Queries | GZIP : On ]