[QUOTE=olavst;35710561]So I want to learn OpenGL. I looked around on the internet for tutorials and stuff, but I only found old stuff about the fixed function pipeline.
Is there any good online tutorials or a good book available for modern OpenGL?[/QUOTE]
[url]http://open.gl/[/url]
[QUOTE=olavst;35711508][IMG]http://i.imgur.com/AvV3w.png[/IMG][/QUOTE]
open.gl is a running FP joke.
[QUOTE=Over-Run;35708997]So I'm trying to make Snakes and Ladders. It works 100% so far, we just need to add in actual Snakes and Ladders, and the other thing is, getting the zig zag pattern to work. So player starts in the bottom left, moves right and instead of going back to the left and up a row, he will move up a row at the right hand side and then go left. How can we do that?
Here is the Snakes class we used: [url]http://pastebin.com/8chwFt2Q[/url]
Would we make it in the move player method or what?[/QUOTE]
This is probably going to be some pretty shitty help because I haven't looked at your code at all, but just from a minute of thinking I've come up with how I'd implement it.
You have your grid of m by n squares, making m*n squares in total. your player token\class keeps track of its location, which will be any value in the range 0 .. m*n (it has to be on one of the squares). whenever its your turn to move, you 'roll the dice' or whatever and get some number of spaces to move. You add that number of spaces to your current position, and get the new position - your player doesn't handle the location of its sprite on-screen, it just keeps track of where it was coming from and going to (so you can do smooth animations).
the board itself will render the tokens in the right spots, so if that means every second row is backwards then that's cool, you can just write two sets of code and run one or the other as a result of row % 2 == 0.
to handle the whole "snakes and ladders" business, once your player token is in its final position (after the smooth animation), you look up the current tile number in a dictionary. if the key doesn't exist - no worries, not a snake or ladder. otherwise if it does exist, the value of that key in the dictionary is the new spot you'd need to move to. you do the smooth animation thing again, and no worries.
so after that large amount of crap largely irrelevant to your question: How do you make the player move in the opposite direction on each row? You keep track of the square the player is in and make the board render the player in the right spot for that square; every second row has an odd index so a modulo 2 operation will tell you if that's the case. If it is, you just draw the square numbers backwards.
Something like that.
[editline]26th April 2012[/editline]
[QUOTE=olavst;35710561]So I want to learn OpenGL. I looked around on the internet for tutorials and stuff, but I only found old stuff about the fixed function pipeline.
Is there any good online tutorials or a good book available for modern OpenGL?[/QUOTE]
In terms of online tutorials - you're shit outta luck, I think. I've been looking for them the same as you and everything I've found, even the stuff claiming that it is modern is using derpecated code. As such, your best bet is to use the OpenGL Superbible, 5th edition. I had a look through it and the stuff I did read was useful, but for the most part I ignored the book and just looked at how their GLTools library did things until I ripped it apart to the point where it worked.
Another completely invaluable resource is the OpenGL 4.0 man pages. Googling any opengl function will probably take you to the old man pages, you can force the new versions by changing "man" to "man4" in the url, eg
http://www.opengl.org/sdk/docs/[b]man[/b]/xhtml/glBufferData.xml
to
http://www.opengl.org/sdk/docs/[b]man4[/b]/xhtml/glBufferData.xml
otherwise, grab yourself a copy of the opengl superbible or an ebook and the complete reference to all core opengl functions is in there. If you find a decent GLSL 4.0 spec, let me know - I'm finding that even more difficult to come across.
Fixed time steps are confusing me greatly. I've read through the favourite article ([url=http://gafferongames.com/game-physics/fix-your-timestep/]this[/url]) but am still lost as to what to do after attempting to implement the process in various different ways.
If, for example, a car was moving at a speed of 100 I would, presumably, simply add 100 to the position of the sprite every update loop. Then when drawing the car draw it at its current position. Or at least that's how I'm used to doing things, but with this fixed time step should there be some multiplication by frame time or something I'm missing somewhere?
Any help is appreciated, thanks.
[QUOTE=Nerr;35712972]Fixed time steps are confusing me greatly. I've read through the favourite article ([url=http://gafferongames.com/game-physics/fix-your-timestep/]this[/url]) but am still lost as to what to do after attempting to implement the process in various different ways.
If, for example, a car was moving at a speed of 100 I would, presumably, simply add 100 to the position of the sprite every update loop. Then when drawing the car draw it at its current position. Or at least that's how I'm used to doing things, but with this fixed time step should there be some multiplication by frame time or something I'm missing somewhere?
Any help is appreciated, thanks.[/QUOTE]
I think you've got your definitions turned on their heads. Fixed time-step is where you have a fixed amount of ticks/updates per second, and variable time-step is having a variable amount of ticks. In a variable time-step it'll usually tick as fast as the system can, and you need to keep track of how long it has been since the last tick. Then you move everything in the game around based on this time.
The nice thing with variable time-step is that if the game runs on a terribly dated computer at a low framerate, the objects in the game will still appear to move as fast they would with a fixed time-step (given that the computer could handle the fixed framerate set). Running the same game on the same computer with fixed time-step would make all the objects move super-slow if it couldn't handle the framerate-cap that is set.
I'm no expert, but I think this should help.
[QUOTE=Nerr;35712972]Fixed time steps are confusing me greatly. I've read through the favourite article ([url=http://gafferongames.com/game-physics/fix-your-timestep/]this[/url]) but am still lost as to what to do after attempting to implement the process in various different ways.
If, for example, a car was moving at a speed of 100 I would, presumably, simply add 100 to the position of the sprite every update loop. Then when drawing the car draw it at its current position. Or at least that's how I'm used to doing things, but with this fixed time step should there be some multiplication by frame time or something I'm missing somewhere?
Any help is appreciated, thanks.[/QUOTE]
What you might be missing is that before Fix Your Timestep there was an article on [url=http://gafferongames.com/game-physics/integration-basics/]Integration Basics[/url].
As a suggestion.
So I'm making this small game: [img]http://puu.sh/rs6d[/img]
And, I need to do collisions, now I have no idea how I would check if these guys collide, can anybody help me with this?
[QUOTE=Mordi;35713210]I think you've got your definitions turned on their heads. Fixed time-step is where you have a fixed amount of ticks/updates per second, and variable time-step is having a variable amount of ticks. In a variable time-step it'll usually tick as fast as the system can, and you need to keep track of how long it has been since the last tick. Then you move everything in the game around based on this time.
The nice thing with variable time-step is that if the game runs on a terribly dated computer at a low framerate, the objects in the game will still appear to move as fast they would with a fixed time-step (given that the computer could handle the fixed framerate set). Running the same game on the same computer with fixed time-step would make all the objects move super-slow if it couldn't handle the framerate-cap that is set.
I'm no expert, but I think this should help.[/QUOTE]
Thanks a lot, that does help.
[QUOTE=esalaka;35713235]What you might be missing is that before Fix Your Timestep there was an article on [url=http://gafferongames.com/game-physics/integration-basics/]Integration Basics[/url].
As a suggestion.[/QUOTE]
I have read that article also but I'm still struggling to understand, thanks for the suggestion though.
[QUOTE=Nerr;35713760]I have read that article also but I'm still struggling to understand, thanks for the suggestion though.[/QUOTE]
The Euler integrator example at the beginning is the simple example and then you get a direct guide to implementing a RK4 integrator because basically as the article states "the Euler Integrator is basically crap and you should never use it".
Mostly because you'd need a smaller timestep for Euler integration to be accurate enough.
[QUOTE=esalaka;35713930]The Euler integrator example at the beginning is the simple example and then you get a direct guide to implementing a RK4 integrator because basically as the article states "the Euler Integrator is basically crap and you should never use it".
Mostly because you'd need a smaller timestep for Euler integration to be accurate enough.[/QUOTE]
I saw a post somewhere claiming that just running Euler a few times for each of your programs steps produces a better result than RK4, I'll see if I can find it.
Edit:
This might have been it:
[url]http://codeflow.org/entries/2010/aug/28/integration-by-example-euler-vs-verlet-vs-runge-kutta/[/url]
it comes to a slightly different conclusion, but shows the Euler can be quite good, but Runge-Kutta is better with less iterations.
[QUOTE=danharibo;35713944]
it comes to a slightly different conclusion, but shows the Euler can be quite good, but Runge-Kutta is better with less iterations.[/QUOTE]
Which is exactly the point of Runge-Kutta: If your timestep was infinitesimal I believe the Euler method should only have infinitesimal error but sometimes you just can't afford a small enough resolution.
Euler is normally enough for most games though to be honest.
For low velocitios there's no huge error anyway yeah but Euler integration seems to mess up things like gravity pretty bad if you want a very realistic simulation.
[QUOTE=esalaka;35713930]The Euler integrator example at the beginning is the simple example and then you get a direct guide to implementing a RK4 integrator because basically as the article states "the Euler Integrator is basically crap and you should never use it".
Mostly because you'd need a smaller timestep for Euler integration to be accurate enough.[/QUOTE]
So should I attach a State (but using vectors) to each of my entities in order to determine their position and velocity and integrate each entity's position and velocity every loop?
That's one way to do it.
Alternatively you just have each entity contain its velocity and location (And possibly acceleration as well..?)
Ah, I think I understand now. I was confused as to whether I needed to integrate them, but that's how you advance their position. Thanks a lot for your help!
Hnnng, okay, I need help with percent stuff in visual basic.
Let's say that I make a calculation of how many people are in certain radius
Theres 150,000 people in the city of facepunchia, and in the 1000 meter radius there's 24% of the total population
But then comes a nuke and about 88% of the folks die in 1000 radius
What is the correct way of putting this in visual basic? And how to prevent it going above 100% so it wont show 151%-kind of results?
No-one has been able to help with this in our class or get it to work correctly nor show proper results
pop = 150000 people
pop density = pop / area of whole city
people in the 1000m radius = 1000^2 pi / area of whole city * pop
if you take it as a percentage, divide both sides by the population and you'll get
24% = 1000^2 pi / area of whole city
so area of whole city * 0.24 = 1000^2 pi
so area of while city = 1000^2 pi / 0.24 = ~13 089 969 metres squared
so number of people in 1000m radius is = ~36000
88% of people die
people in the 1000m radius after explosion = (100 - 88)/100 * people in the 1000m radius
= 0.12 * people in 1000m radius
= ~4320 people alive
assuming no casualties outside the 1000m radius, the percentage of people that have died is
percentage of people in radius * percentage of people who died = 0.24 * 0.88 = 0.2112 = 21.12% of total population is dead
% people alive = 100 - % dead = 100 - 21.12 = 78.88% of total population is alive
pretty sure this maths is right
[QUOTE=mechanarchy;35718134]pop = 150000 people
pop density = pop / area of whole city
people in the 1000m radius = 1000^2 pi / area of whole city * pop
if you take it as a percentage, divide both sides by the population and you'll get
24% = 1000^2 pi / area of whole city
so area of whole city * 0.24 = 1000^2 pi
so area of while city = 1000^2 pi / 0.24 = ~13 089 969 metres squared
so number of people in 1000m radius is = ~36000
88% of people die
people in the 1000m radius after explosion = (100 - 88)/100 * people in the 1000m radius
= 0.12 * people in 1000m radius
= ~4320 people alive
assuming no casualties outside the 1000m radius, the percentage of people that have died is
percentage of people in radius * percentage of people who died = 0.24 * 0.88 = 0.2112 = 21.12% of total population is dead
% people alive = 100 - % dead = 100 - 21.12 = 78.88% of total population is alive
pretty sure this maths is right[/QUOTE]
Thanks a bunch! Really helped me with this thing.
I am making a nuclear strike simulator where you can choose a country, and a city from that cuntry, then a nuclear warhead (starting with 25kt fatman and going up). It's fairly simple right now but I am planning to have it in the more "advanced" stages to calculate the psi of blast, radiation, and thermal radiation per 2,5 kt. Along with animations and graphics.
[QUOTE=smeismastger;35718172]Thanks a bunch! Really helped me with this thing.
I am making a nuclear strike simulator where you can choose a country, and a city from that cuntry, then a nuclear warhead (starting with 25kt fatman and going up). It's fairly simple right now but I am planning to have it in the more "advanced" stages to calculate the psi of blast, radiation, and thermal radiation per 2,5 kt. Along with animations and graphics.[/QUOTE]
yeah i'm pretty sure i remembered reading a couple of your posts earlier in this thread or waywo. hope it's going well, now you've got that bit of maths done.
I'm not sure how you'd do the calculations with the more advanced things - psi, equivalent weight in TNT, etc, but if you can just approximate it to a percentage like you've done there it's easy
[QUOTE=mechanarchy;35718194]yeah i'm pretty sure i remembered reading a couple of your posts earlier in this thread or waywo. hope it's going well, now you've got that bit of maths done.
I'm not sure how you'd do the calculations with the more advanced things - psi, equivalent weight in TNT, etc, but if you can just approximate it to a percentage like you've done there it's easy[/QUOTE]
Oh I got the math down for them alright, its just getting them into a working order in Visual Basic and with correct functions and marks. Making percentage calculations in Visual basic 2010 can be annoying.
[QUOTE=smeismastger;35718236]Oh I got the math down for them alright, its just getting them into a working order in Visual Basic and with correct functions and marks. Making percentage calculations in Visual basic 2010 can be annoying.[/QUOTE]
hah, tell me about it. making pretty much anything in visual basic is annoying. i think its only redeeming feature is the with statement, example from msdn
[code]
With testObject
.Height = 100
.Text = "Hello, World"
.ForeColor = System.Drawing.Color.Green
.Font = New System.Drawing.Font(.Font, _
System.Drawing.FontStyle.Bold)
End With
[/code]
i don't think i've seen an analog for it in any other language
[QUOTE=mechanarchy;35718319]hah, tell me about it. making pretty much anything in visual basic is annoying. i think its only redeeming feature is the with statement, example from msdn
[code]
With testObject
.Height = 100
.Text = "Hello, World"
.ForeColor = System.Drawing.Color.Green
.Font = New System.Drawing.Font(.Font, _
System.Drawing.FontStyle.Bold)
End With
[/code]
i don't think i've seen an analog for it in any other language[/QUOTE]
javascript:
[cpp]
var a = { x: null, y: null };
with(a) {
x = 123;
y = 456;
}
[/cpp]
[QUOTE=mechanarchy;35718319]hah, tell me about it. making pretty much anything in visual basic is annoying. i think its only redeeming feature is the with statement, example from msdn
[code]
With testObject
.Height = 100
.Text = "Hello, World"
.ForeColor = System.Drawing.Color.Green
.Font = New System.Drawing.Font(.Font, _
System.Drawing.FontStyle.Bold)
End With
[/code]
i don't think i've seen an analog for it in any other language[/QUOTE]
C#
[cpp]
TestObject testObject = new TestObject { Height= 100, Text= "Hello, World"};
[/cpp]
It's not the same, but similar.
[QUOTE=Simspelaaja;35719319]C#
[cpp]
TestObject testObject = new TestObject { Height= 100, Text= "Hello, World"};
[/cpp]
It's not the same, but similar.[/QUOTE]
similar, sure, but can you use it outside a constructor?
I know python lets you use named parameters for functions but it's not really the same thing as accessing arbitrary properties of an object
I implemented the fixed timestep into a sample project in order to try and get it working on its own.
[cpp] var texture = new Texture("image.png");
var sprite = new Sprite(texture) {Position = new Vector2f(500, 300f)};
State current;
current.x = 500;
current.v = 0;
State previous = current;
float t = 0f;
float dt = 0.1f;
float currentTime = 0f;
float accumulator = 0f;
while (window.IsOpen())
{
window.DispatchEvents();
window.Clear();
float newTime = Time();
float deltaTime = newTime - currentTime;
currentTime = newTime;
if (deltaTime > 0.25f) deltaTime = 0.25f;
accumulator += deltaTime;
while (accumulator >= dt)
{
accumulator -= dt;
previous = current;
Maths.Integrate(ref current, t, dt);
t += dt;
}
State state = Maths.Interpolate(ref previous, ref current, accumulator / dt);
sprite.Position = new Vector2f(state.x, sprite.Position.Y);
window.Draw(sprite);
window.Display();
}[/cpp]
Does the code above show the correct way of implementing it? If so, I'm confused by the variables contained by a State. Within integration basics ([url=http://gafferongames.com/game-physics/integration-basics/]here[/url]) it states that x is position and v is velocity; if so, why does the square move until x reaches zero with no velocity set? Have I implemented something wrongly (maths class is [url=https://gist.github.com/6a53ea512397f823a46f]here[/url])?
I've decided to dabble in Adobe AIR but I really can't find any good guide to it. It's like it's non-existent.
While in Java Processing...
I have been trying to move the view port in processing so I changed the rendering mode from JAVA2D to P3D so I can use the camera function. The graphics have gone from really good to, well shit to say the least. Eclipses went from being an eclipse to a kinda round polygon kind of thing.
Aside from these problems the when I zoom out and call the mouseX and mouseY function it gets the screens mouseX and mouseY but the cords have no coloration to the spot in the world that it is over. I tried finding a scale factor for the screen to the camera but I haven't had any luck. What do you guys recommend to do?
Sorry, you need to Log In to post a reply to this thread.