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

Login with username, password and session length

 
Advanced search

1057315 Posts in 42950 Topics- by 34889 Members - Latest Member: Vergil

October 25, 2014, 12:38:16 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)What are you programming RIGHT NOW?
Pages: 1 ... 43 44 [45] 46 47 ... 66
Print
Author Topic: What are you programming RIGHT NOW?  (Read 115107 times)
Lee
Level 1
*


View Profile
« Reply #880 on: March 29, 2013, 08:43:12 AM »

I needed an efficient sorting method to make my collision checks not be O(n^2) so I came up with a tree based sorting algorithm:
(original data set: 51,50,9000,1,60,100,82,80,0,52,51,50,1536,48,8,6558,2,5644,1,45)


Here's the code for it:
code:
Code:
void treesort()
{
int data[20] = {51,50,9000,1,60,100,82,80,0,52,51,50,1536,48,8,6558,2,5644,1,45};
int num_items = 20;
int check=0;
int tmp=0;
int node=0;//current node
int c_node=0;//comparison node
//treeify
for (int i=1; i<num_items;i++){
//enforce rule that parents must be higher value
for (int i2=i+1;i2>1;i2/=2){
check++;
c_node =(i2/2)-1;
node = i2-1;
if (data[node]>data[c_node]){
tmp=data[c_node];data[c_node]=data[node];data[node]=tmp;//swap
}
else {break;}
}
}
//print
printf("tree before sort:\n");
for (int i=0; i<num_items; i++){
printf("%d ",data[i]);
}
printf("\nnumchecks: %d\n",check);
//sort
int last = num_items-1;
for (int i=num_items-1-((num_items-1)&1); i>1; i-=2){
check++;
//if right hand branch then enforce rule that it must be smaller than left hand branch
if (data[i]>data[i-1]){
tmp=data[i-1];data[i-1]=data[i];data[i]=tmp;
}
//then check if next pair is bigger
for (int i2=last;i2>i;i2--){
check++;
//check against current branch lower val, if higher then low val check against current branch higher val
if (data[i]<data[i2]){
check++;
tmp=data[i2];data[i2]=data[i];data[i]=tmp;//swap
if (data[i-1]<data[i]){
tmp=data[i];data[i]=data[i-1];data[i-1]=tmp;//swap
last = i-1;
}
else{last = i;}
}
}
}
//print
printf("sorted values:\n");
for (int i=0; i<num_items; i++){
printf("%d ",data[i]);
}
printf("\nnumchecks: %d\n",check);
}
Didn't research into any specifics regarding current sorting methods, this pretty much came from some mad scribblings and going through it by hand on paper. I did look into how a basic tree structure is made to figure out how I could build a tree without using a data structure with left/right branches, but then I just realized each pair of numbers represents a branch and n/2 moves up and n*2 moves down and it was pretty simple from there. I don't think the order of objects is swapped if they're the same value when they're tree-ified, I may be wrong but it's not really important to me... The complexity in total is O(3(nlogn))? I don't really understand the n*log(n) business or how that comes about but it's definitely not n^2 or linear.

If you can spot any errors or possible optimizations it'd be great if you'd let me know.
Logged
rivon
Level 10
*****



View Profile
« Reply #881 on: March 29, 2013, 09:17:48 AM »

If you only need to sort an array of ints then use quicksort. It has O(n*logn) complexity... It's built-in in pretty much any language.
Logged
Klaim
Level 10
*****



View Profile WWW
« Reply #882 on: March 29, 2013, 10:13:44 AM »

Made my game (if you can call that a game already...) all different cpu cores with equally distributed workload.

Now back to graphic code.
Logged

http://www.klaimsden.net | Game : NetRush | Digital Story-Telling Technologies : Art Of Sequence
indietom
Level 2
**

Tom


View Profile Email
« Reply #883 on: March 29, 2013, 11:26:24 AM »

Testing out sdlbasic because I want to try out something different then c++ just for the fun.
Logged

Code::Blocks
This is my profile, there are many like it but this one is mine.
Joshua
Level 5
*****


Be rad to one another!


View Profile WWW Email
« Reply #884 on: March 29, 2013, 11:49:26 AM »

A little proof of concept demo for a basic FOV algorithm. Interactive Version at JSBin



Logged

t-recx
Level 0
**


View Profile
« Reply #885 on: March 29, 2013, 12:45:26 PM »

A gui framework for XNA:


Logged
xapa112
Manbaby
*


View Profile Email
« Reply #886 on: March 30, 2013, 08:34:40 AM »

I'm learning Python, so i'm making some basic sripts.
Logged
Jubjub
Level 1
*



View Profile
« Reply #887 on: March 30, 2013, 10:51:59 AM »

A gui framework for XNA

Those are some nice-looking controls.
Logged
Dataflashsabot
Level 2
**


View Profile
« Reply #888 on: March 31, 2013, 04:42:40 AM »

Encapsulated my framerate-limiting code into a Throttle class.
Code:
Throttle throt(33);
while(myGame.isRunning())
{
    auto deltaMs = throt.wait();
    myGame.doSomething(deltaMs); // will run no more often than every 33ms
}

Makes use of my Stopwatch class which makes use of C++11's std::chrono.
Logged
Klaim
Level 10
*****



View Profile WWW
« Reply #889 on: March 31, 2013, 05:06:49 AM »

Beware if you compile with MSVC, the granularity of std::chrono is very bad and will be in the next version too. Source: https://connect.microsoft.com/VisualStudio/feedback/details/719443/

I've hit some time precision problems because of this recently. The simplest solution is to use boost::chrono instead as it is very precise, but it forces you to use boost::thread instead of std::thread if you are using timing facilities like std::condition_variable or std::this_thread::sleep_for/until().

Just know that current std::chrono implementaitons are not yet all equivalent. Unfortunately I think it will be true until next year  Tired
Logged

http://www.klaimsden.net | Game : NetRush | Digital Story-Telling Technologies : Art Of Sequence
InfiniteStateMachine
Level 10
*****



View Profile WWW Email
« Reply #890 on: March 31, 2013, 05:57:48 AM »

A gui framework for XNA:




damn you really went all the way on that +D

nice work!
Logged

Dataflashsabot
Level 2
**


View Profile
« Reply #891 on: March 31, 2013, 06:04:57 AM »

Beware if you compile with MSVC, the granularity of std::chrono is very bad and will be in the next version too. Source: https://connect.microsoft.com/VisualStudio/feedback/details/719443/

I've hit some time precision problems because of this recently. The simplest solution is to use boost::chrono instead as it is very precise, but it forces you to use boost::thread instead of std::thread if you are using timing facilities like std::condition_variable or std::this_thread::sleep_for/until().

Just know that current std::chrono implementaitons are not yet all equivalent. Unfortunately I think it will be true until next year  Tired
Nope, I'm using GCC on all platforms and it's plenty accurate. But that might be a problem, because I was wanting to package up my various helper classes and release them as "handylib". I don't want to use boost so that leaves me rolling my own cross-platform timing system if I want it to be MSVC-compatible. I'll see.

My current version of GCC for windows doesn't support std::thread, so I've rolled my own crude threading wrapper for Windows and eventually POSIX. It leaves much to be desired- in particular, you can't yet pass an arbitrary thread function (must be void(void)). I don't intend to use it for much except animated loading screens, though.
Logged
t-recx
Level 0
**


View Profile
« Reply #892 on: March 31, 2013, 06:16:23 AM »


Those are some nice-looking controls.

damn you really went all the way on that +D

nice work!

Thanks :3
I'm keeping a repository here if someone happens to need it. It's completely undocumented at the moment tho.
Logged
Klaim
Level 10
*****



View Profile WWW
« Reply #893 on: March 31, 2013, 06:38:08 AM »


Nope, I'm using GCC on all platforms and it's plenty accurate. But that might be a problem, because I was wanting to package up my various helper classes and release them as "handylib". I don't want to use boost so that leaves me rolling my own cross-platform timing system if I want it to be MSVC-compatible. I'll see.


If you do this, you would only have to write a clock like std::chrono::high_performance_clock yourself and still use std::chrono for the rest.

Quote
My current version of GCC for windows doesn't support std::thread, so I've rolled my own crude threading wrapper for Windows and eventually POSIX. It leaves much to be desired- in particular, you can't yet pass an arbitrary thread function (must be void(void)). I don't intend to use it for much except animated loading screens, though.


Yeah if you just spawn a thread at some point and it's not the basic way your system work, it's ok to not use std/boost::thread or anything else.
Logged

http://www.klaimsden.net | Game : NetRush | Digital Story-Telling Technologies : Art Of Sequence
kamac
Level 10
*****


Notorious posts editor


View Profile Email
« Reply #894 on: March 31, 2013, 01:44:41 PM »

Testing out sdlbasic because I want to try out something different then c++ just for the fun.


Ooh! I've used to use it years ago for PSP development Tongue
Didn't go far, though as I spotted the interpreter is slow as hell.
Logged

Nothing to do here
indie11
Level 1
*


View Profile
« Reply #895 on: March 31, 2013, 05:39:25 PM »

Working on a platformer game for android.
Off topic, I really want to learn C++ game development as most of the game development jobs require fluency in C++. So where to start?
Logged
TomHunt
Level 3
***



View Profile WWW Email
« Reply #896 on: March 31, 2013, 09:04:15 PM »

I really want to learn C++ game development as most of the game development jobs require fluency in C++. So where to start?
A four year computer science degree will put you well on your way. (make sure the school uses C++ in its coursework)

Also, this: Teach Yourself Programming in Ten Years

Some books to read: Stroustrup, more Stroustrup, Effective C++, More Effective C++, Code Complete, Game Coding Complete, Gang of Four, Refactoring, and Knuth

that's a list of the biggies. there are many many others you could read, but you probably want to reach your goal within this lifetime.

Also, probably one or two books on game engine programming. if there's a particular specialization you're interested in (AI, graphics, animation, etc), obviously that's what you'll want to focus on, but it's always good to read broadly.

so, lots of big thick books.

also, write lots and lots of C++ code. practice, practice, practice.

learning to program is like learning a martial art. it takes years if not decades to really gain a true mastery, although you might be fooled into thinking otherwise from seemingly rapid initial progress. start with fundamentals - get the core C++ stuff down pat while working with existing libraries and engines - libSDL is great for this, then eventually get into writing your own engine stuff.

when you can write your own game from the ground up from scratch (and probably have a few self-developed games under your belt by this time), i'm sure you'll have a pretty nice resume to hand to a AAA company at the GDC career fair, along with a few cool demos.

(mod: feel free to fork this)
Logged

~tom | kRYSTLR
Twinklebear
Level 0
**


View Profile
« Reply #897 on: April 01, 2013, 12:23:14 AM »

After reading a blog on working with C++11 tuples I got curious about using them and variadic templates to generate Lua bindings. It's sort of coming along but I'm still stuck on a few things, currently I must define a wrapper function that gets the arguments from Lua, calls the function and then pushes a result back since I'm still working on figuring out how to generate this wrapper function in a way that can be handed off to Lua.

The code I've got so far is this Gist if anyone's curious. I'll probably go bug the folks at the Lua IRC for some tips at some point heh.
Logged
indie11
Level 1
*


View Profile
« Reply #898 on: April 01, 2013, 01:01:56 AM »

I really want to learn C++ game development as most of the game development jobs require fluency in C++. So where to start?
A four year computer science degree will put you well on your way. (make sure the school uses C++ in its coursework)

Also, this: Teach Yourself Programming in Ten Years

Some books to read: Stroustrup, more Stroustrup, Effective C++, More Effective C++, Code Complete, Game Coding Complete, Gang of Four, Refactoring, and Knuth

that's a list of the biggies. there are many many others you could read, but you probably want to reach your goal within this lifetime.

Also, probably one or two books on game engine programming. if there's a particular specialization you're interested in (AI, graphics, animation, etc), obviously that's what you'll want to focus on, but it's always good to read broadly.

so, lots of big thick books.

also, write lots and lots of C++ code. practice, practice, practice.

learning to program is like learning a martial art. it takes years if not decades to really gain a true mastery, although you might be fooled into thinking otherwise from seemingly rapid initial progress. start with fundamentals - get the core C++ stuff down pat while working with existing libraries and engines - libSDL is great for this, then eventually get into writing your own engine stuff.

when you can write your own game from the ground up from scratch (and probably have a few self-developed games under your belt by this time), i'm sure you'll have a pretty nice resume to hand to a AAA company at the GDC career fair, along with a few cool demos.

(mod: feel free to fork this)

Well I just completed my 4 years computer science degree. I studied C++ in first three semesters and after that switched to java(which i regret now), I have done OOP and Data structures in C++ but have never tried any graphical or game programming in C++ though I have done that in Java and AS3. Is it fine to start off with a C++ game programming book then?
Logged
TomHunt
Level 3
***



View Profile WWW Email
« Reply #899 on: April 01, 2013, 02:54:00 AM »

I'd start with Code Complete then. It's not at all specific to game development, but still entirely relevant to any software engineering endeavor (which is a good thing). Game Coding Complete will complement that a bit with some more game dev specific things.

Also, make a simple game or five in C++, start to finish. That's probably going to be the best way to really learn how to do game programming in any language. Check out SDL and SFML. Gamedev.net has loads of articles and tutorials for free.
Logged

~tom | kRYSTLR
Pages: 1 ... 43 44 [45] 46 47 ... 66
Print
Jump to:  

Theme orange-lt created by panic