[QUOTE=Goz3rr;43206521]Changed it to that, updates per second is still 62-64. (Also i misread the article interpolation is supposed to be 0-1 so i'll assume that's working right now). Another problem i noticed is that when the fps is really low the interpolation will keep increasing
I'm using this to see how often it updates:
[code]
private readonly Stopwatch _testWatch = new Stopwatch();
private readonly TimeSpan _sample = TimeSpan.FromSeconds(1);
private TimeSpan _span;
private TimeSpan _prevSpan;
private int _updates;
protected override void Update() {
if(!_testWatch.IsRunning) _testWatch.Start();
_span += _testWatch.Elapsed - _prevSpan;
_prevSpan = _testWatch.Elapsed;
_updates++;
if(_span > _sample) {
Console.WriteLine(_updates);
_updates = 0;
_span -= _sample;
}
}
[/code][/QUOTE]
Only query the stopwatch once in your main loop (not in Update()) and use local variables instead of fields (why??).
Pass the time difference into your Update() method, for example using a
[code]public delegate void UpdateHandler(float deltaTime);[/code]
Cap the time difference in the main method to something like two seconds so you discard a few updates instead of running into progressively worse delays.
You get too many FPS because the integer division 1000 / 60 rounds down to 16, which is 1000 / 62.5.
17 is slightly more accurate with 58.8... FPS, but milliseconds are too inaccurate here if you want a correct solution.
any help will be greatly appreciated
[code]
#include <iostream>
using namespace std;
int foo[] = {16, 2, 77, 40, 12071};
int n, result=0;
int main()
{
for( n=0 ; n < 5 ; ++n)
{
result += foo[n];
}
cout << result;
return 0;
}
[/code]
I recieve 12206 as an output but it must output 12216 because progress is like this:
0 = 0 + 16
1 = 1 + 2
2 = 2 + 77
3 = 3 + 40
4 = 4 + 12071
and the final value must be 12216 but why this program gives me 12206 i cant understand it. Can somebody help me ?
[QUOTE=Tamschi;43214557]Only query the stopwatch once in your main loop (not in Update()) and use local variables instead of fields (why??).
Pass the time difference into your Update() method, for example using a
[code]public delegate void UpdateHandler(float deltaTime);[/code]
Cap the time difference in the main method to something like two seconds so you discard a few updates instead of running into progressively worse delays.
You get too many FPS because the integer division 1000 / 60 rounds down to 16, which is 1000 / 62.5.
17 is slightly more accurate with 58.8... FPS, but milliseconds are too inaccurate here if you want a correct solution.[/QUOTE]
That code is what i use to measure the updates per second, not the actual game loop.
I changed
[code]
private const float SkipTime = 1000 / 60;
[/code]
to
[code]
private const float SkipTime = 1000f / 60f;
[/code]
And now it updates at the proper 60/s
[QUOTE=vBatuhan;43215228]any help will be greatly appreciated
[code]
#include <iostream>
using namespace std;
int foo[] = {16, 2, 77, 40, 12071};
int n, result=0;
int main()
{
for( n=0 ; n < 5 ; ++n)
{
result += foo[n];
}
cout << result;
return 0;
}
[/code]
I recieve 12206 as an output but it must output 12216 because progress is like this:
0 = 0 + 16
1 = 1 + 2
2 = 2 + 77
3 = 3 + 40
4 = 4 + 12071
and the final value must be 12216 but why this program gives me 12206 i cant understand it. Can somebody help me ?[/QUOTE]
For some reason you seem to think n gets added as well. This does not happen. What it does is:
16 + 2 + 77 + 40 + 12071 == 12206.
It does not do 16 + 1 + 2 + 2 + 77 + 3 + 40 + 4 + 12071 == 12216.
[QUOTE=mobrockers;43215329]For some reason you seem to think n gets added as well. This does not happen. What it does is:
16 + 2 + 77 + 40 + 12071 == 12206.
It does not do 16 + 1 + 2 + 2 + 77 + 3 + 40 + 4 + 12071 == 12216.[/QUOTE]
because there is += operator and I think it like:
result = result + foo[n];
I still can't understand why "n" not added to result when there is += operator can you explain me please and thanks for your respond
[QUOTE=vBatuhan;43215464]because there is += operator and I think it like:
result = result + foo[n];
I still can't understand why "n" not added to result when there is += operator can you explain me please and thanks for your respond[/QUOTE]
Your idea is half correct, it does do result = result + foo[n];
But, foo[n] == 16, or 2, or 77, or 40, or 12071, not (0 + 16), (1 + 2), (2 + 77), (3 + 40), or (4 + 12071).
Your array has 5 items, (0, 1, 2, 3, 4), you can access one of these items by calling foo[n] where n is (0, 1, 2, 3, 4), all this does is make it clear which array item you want to access, it does not add anything to the array item.
I'm not sure how to make this clearer, perhaps someone else can explain it better.
[QUOTE=mobrockers;43215569]Your idea is half correct, it does do result = result + foo[n];
But, foo[n] == 16, or 2, or 77, or 40, or 12071, not (0 + 16), (1 + 2), (2 + 77), (3 + 40), or (4 + 12071).
Your array has 5 items, (0, 1, 2, 3, 4), you can access one of these items by calling foo[n] where n is (0, 1, 2, 3, 4), all this does is make it clear which array item you want to access, it does not add anything to the array item.
I'm not sure how to make this clearer, perhaps someone else can explain it better.[/QUOTE]
Oh i understand now thank you so the program really works like this:
0 = 0 + 16
16 = 16 + 2
18 = 18 + 77
95 = 95 + 40
135 = 135 + 12071
instead of adding n to result it assign inside of n to result and add each element with each other which elements are at the same time equals to result.
Anyone good with Cortex Command lua? :v
[code]function Create(self)
self.lifeTimer = Timer();
self.Vel = self.Vel*0.50;
end
function Update(self)
self.AngularVel = 10;
if self.lifeTimer:IsPastSimMS(5000) then
local explosion = CreateMOSRotating("Ronin RPC Explosion");
explosion.Pos = self.Pos;
explosion:GibThis();
MovableMan:AddParticle(explosion);
self.ToDelete = true;
else
self.ToDelete = false;
self.Vel = self.Vel*1.03;
end
end
[/code]
You're looking at a projectile which is coming out of a gun.
I want the projectile to travel along the curve of a sine function, because it would be badass.
The thing is, the only way to set motion is through a property called Velocity, which is given through a vector.
I can change the projectile's velocity every time Update() runs (every tick I think)
[url]http://wiki.datarealms.com/LuaDocs/MovableObject[/url]
What it does:
[img]http://i.imgur.com/nULIQdL.png[/img]
What I want:
[img]http://i.imgur.com/xACuGoX.png[/img]
Any good ideas?
- What are some good resources to learn about software engineering concepts (version control, project design, workflow, etc)? All the programming I've ever done has been individual projects on my own machine that were never updated once they were finished. How can I learn actual industry practices?
- Are there any good IDE's for Prolog?
- If you aren't artistically inclined (even basics), is it worth delving into the world of game and/or website design? I'd love to design my own website to act as a portfolio but I fear my lack of artistic abilities will only slow me down to a crawl.
[QUOTE=MWSunder;43219309]- What are some good resources to learn about software engineering concepts (version control, project design, workflow, etc)? All the programming I've ever done has been individual projects on my own machine that were never updated once they were finished. How can I learn actual industry practices?
- Are there any good IDE's for Prolog?
- What's a good OOPL to familiarize myself with if I want to design graphical applications as quickly as possible? Ruby? Smalltalk?
- If you aren't artistically inclined (even basics), is it worth delving into the world of game and/or website design? I'd love to design my own website to act as a portfolio but I fear my lack of artistic abilities will only slow me down to a crawl.[/QUOTE]
If it's just a portfolio of programming and not design projects you could just throw together a simple bootstrap website, it shouldn't be too hard.
[QUOTE=war_man333;43217270]Anyone good with Cortex Command lua? :v
You're looking at a projectile which is coming out of a gun.
I want the projectile to travel along the curve of a sine function, because it would be badass.
The thing is, the only way to set motion is through a property called Velocity, which is given through a vector.
I can change the projectile's velocity every time Update() runs (every tick I think)
[url]http://wiki.datarealms.com/LuaDocs/MovableObject[/url]
Any good ideas?[/QUOTE]
The derivative of position is velocity, so if you want it to be a sin function you'll need to work out the velocity vector as a cosine function. I'd split it into a normal and tangential reference point, ie the forwards movement and the normal oscillation given by the cos, then just change that into the cartesian plane using some trigonometry. :smile: I don't know anything about lua so I can't help much more than that unfortunately.
I think with an hour or two I could figure out the math as well. I'm not very good with explaining and understanding math in english though.
The problem is the lua, I don't know how it works.
I found help on the Data Realms (Cortex Command) forums!
[QUOTE=MWSunder;43219309][...]
- If you aren't artistically inclined (even basics), is it worth delving into the world of game and/or website design? I'd love to design my own website to act as a portfolio but I fear my lack of artistic abilities will only slow me down to a crawl.[/QUOTE]
I'm pretty bad at art (from an execution point of view though) but I think relatively ok-ish at functional/UI design, so there's not [I]that[/I] much of a correlation in my opinion.
[URL="http://www.penny-arcade.com/patv/show/extra-credits/"]Game design[/URL] is a completely different story, it's likely closer to engineering than traditional art (although art can be engineering in some cases).
I think it comes down to a mixture of [URL="https://www.youtube.com/watch?v=9C_HReR_McQ"]being creative[/URL] and analysing human behaviour, in addition to doing a ton of research.
My problem is: I don't know what to do with all those commands I am given.
I've got this nice book "PROGRAMADOR .NET" which starts off teaching how to program in C#. Helpful and detailed: bits, integers, OOB programming is explained, there are some "Hello Worlds" exercises, do, i++, while, for, etc etc
But thing is: How can I do things, for example: a simple game gameplay mod (a new mechanic) or stuff that helps me with my studies? I don't want nor I think about doing a Microsoft Office program nor a new game from scratch. Just be able to do something basic or modify/add something to a an already existing program.
It's like I have this, stupid creative block in my head that doesn't allow me to do anything related to programming.
Has anyone had this problem? If so, how can I overcome it?
[QUOTE=Cutthecrap;43223146]My problem is: I don't know what to do with all those commands I am given.
I've got this nice book "PROGRAMADOR .NET" which starts off teaching how to program in C#. Helpful and detailed: bits, integers, OOB programming is explained, there are some "Hello Worlds" exercises, do, i++, while, for, etc etc
But thing is: How can I do things, for example: a simple game gameplay mod (a new mechanic) or stuff that helps me with my studies? I don't want nor I think about doing a Microsoft Office program nor a new game from scratch. Just be able to do something basic or modify/add something to a an already existing program.
It's like I have this, stupid creative block in my head that doesn't allow me to do anything related to programming.
Has anyone had this problem? If so, how can I overcome it?[/QUOTE]
Learning C#? Download Unity 4. Play with the example games, or the free example assets on the asset-store, look over their code and try to understand whats happening - or just start small from scratch. The Unity 4 2D toolkit & workflow video of it on youtube would be a good place to start, and their example is really nice. It will be much easier to code when your being entertained while learning.
[QUOTE=Looter;43223175]Learning C#? Download Unity 4. Play with the example games, or the free example assets on the asset-store, look over their code and try to understand whats happening - or just start small from scratch. The Unity 4 2D toolkit & workflow video of it on youtube would be a good place to start, and their example is really nice. It will be much easier to code when your being entertained while learning.[/QUOTE]
Oh, forgot to mention. I also tried to learn batch...python....java. Even made an attempt at modding Minecraft but that....didn't even fail, because I couldn't try anything.
Thanks for the tip, maybe it will give me a hand at understanding things!!!
[QUOTE=Cutthecrap;43223207]Oh, forgot to mention. I also tried to learn batch...python....java. Even made an attempt at modding Minecraft but that....didn't even fail, because I couldn't try anything.
Thanks for the tip, maybe it will give me a hand at understanding things!!![/QUOTE]
Trying to mod Minecraft isn't anywhere close to being a reasonable opportunity to learn programming, unless you use one of the frameworks.
Working with decompiled code is usually pretty advanced because there's a ton of information missing that isn't central to the programs execution.
When your streaming content from a server to a client (say music/video to html5/js/app) is it all up to the client to implement streaming?
ie. does the server simply tell the client the location of the file and the client then manages it
or does the server give the client the required chunk of the file for it to then use?
[QUOTE=Richy19;43230817]When your streaming content from a server to a client (say music/video to html5/js/app) is it all up to the client to implement streaming?
ie. does the server simply tell the client the location of the file and the client then manages it
or does the server give the client the required chunk of the file for it to then use?[/QUOTE]
It depends, with HTTP you can run the server normally (with resume enabled if you want to skip around) and start playing back the partial download on the client, but real-time or lossy streaming will require some set-up on the server and possibly a different protocol.
-snip-
I got it! All it took was believing in myself.
So I was looking into creating a small app for my phone, just to kinda play around and see what I can do. Then I found out you have to buy a license. A $100 license. Apple is crazy. So what are some alternatives?
[QUOTE=Nookyava;43239746]So I was looking into creating a small app for my phone, just to kinda play around and see what I can do. Then I found out you have to buy a license. A $100 license. Apple is crazy. So what are some alternatives?[/QUOTE]
You can make decent "apps" as touch-optimised websites, if you look at the ones offered by Firefox you should get a few ideas about what is possible.
Otherwise there's really nothing you can do short of jailbreaking your device.
(Assuming there are alternative dev-tools.)
[QUOTE=Tamschi;43241208]Otherwise there's really nothing you can do short of jailbreaking your device.
(Assuming there are alternative dev-tools.)[/QUOTE]
There's even gcc on jailbroken iOS.
Every single time I try to do a math problem with programming (like a program in project Euler) I keep getting stuck at really fucking simple stuff and it really brings me down. Like, I get stuck on a problem and look at other people solutions and find stuff that's really simple but I don't know how it works. This always happens. Either I make a solution that works but is really dirty and looks bad, or I can't figure it out and find that it's really simple. Does anyone have any tips on how they approach problems?
[QUOTE=NixNax123;43241715]Every single time I try to do a math problem with programming (like a program in project Euler) I keep getting stuck at really fucking simple stuff and it really brings me down. Like, I get stuck on a problem and look at other people solutions and find stuff that's really simple but I don't know how it works. This always happens. Either I make a solution that works but is really dirty and looks bad, or I can't figure it out and find that it's really simple. Does anyone have any tips on how they approach problems?[/QUOTE]
Use a sheet of paper, write everything you have and everything you need, make smaller issues out of bigger issues, and solve one by one each of them. (red markers + white boards = image imprinted in your brain)
Try solving issues outside of your main project if possible- A testbed project is always easier to work with, since it gives you a cleaner environment and allows you to clean up code during the process of transfering the solution to your main project.
Also, code revision. If you can get someone to read your code, ie WAYWO-like threads, you'll improve a lot over time.
So I have a concurrency assignment I have to do, about having people call an elevator that will bring them to their destination floor.
I don't really know how I can continuously generate people and have the program run indefinitely. I know I can use while(true), but I don't know how I can just keep creating people and having them use the elevator.
[url]http://stackoverflow.com/questions/20703576/java-concurrency-wake-up-thread/20703972?noredirect=1#20703972[/url]
There is the question in more detail on stack overflow. Would appreciate any help with this.
[QUOTE=Over-Run;43249306]So I have a concurrency assignment I have to do, about having people call an elevator that will bring them to their destination floor.
I don't really know how I can continuously generate people and have the program run indefinitely. I know I can use while(true), but I don't know how I can just keep creating people and having them use the elevator.
[url]http://stackoverflow.com/questions/20703576/java-concurrency-wake-up-thread/20703972?noredirect=1#20703972[/url]
There is the question in more detail on stack overflow. Would appreciate any help with this.[/QUOTE]
You could put the wakeup call into the method that is used to queue up the people in front of the elevator doors, that also nicely continues the analogy because it's equivalent to pushing the call button, in a way. The elevator should have a flags array for the floors it's been called to (and possibly the directions from that floor, if you want to make it complicated).
Apparently what you're looking for are the .pause() and .proceed() methods, which seem to be not thread safe (or at least the example has them in a synchronized block).
The elevator should be able to pause itself once there are no pending actions.
Thanks for the advice.
So your saying once the queue of people is empty, initiate the wakeup call?
How would I go about by continuously generating a new person? Maybe like a random time within 5 seconds?
So Person 1 is on floor 1 and presses the button, the elevator goes there and gets him, brings him to his destination floor which is floor 5, and then the elevator waits until a person is created.
I was thinking that when a person is created it just calls the GetElevator method in the person class which wakes the elevator
Having a bit of a dumb moment here, Im trying to implement different difficulties.
I have a map file with 4 enemies and I want a system whereby depending on the difficulty (easy, medium, hard) it places 2, 3, 4 enemies.
This is the way I am doing it:
[csharp]
int enemyFound = 0;
foreach char in the map:
if (levelRaw.GetAt(x, y) == 'e')
{
if ((enemyFound % GlobalSettings.EnemyFrequency) == 0)
{
objects.Add(new Enemy(game, new Vector3(x, 0, y), levelRaw));
enemies++;
}
enemyFound++;
}
[/csharp]
Where GlobalSettings.EnemyFrequency is an integer with value 3, 2, 1 depending on the difficulty
But with both easy and medium its spawning 2 enemies
snip
Sorry, you need to Log In to post a reply to this thread.