Thursday, July 12, 2012

Hiatus ~

Dear Reader,

The last several weeks your humble blog poster has had a significant change. You would benefit greatly from reading this book, it will routinely affect your life, and you'll be a happier person!

 Dale Carnegie's Famous, "How to Win Friends and Influence People"

Relevant To Those Interested Only In Programming:


Your author has also had a chance to learn some Assembly, what a rush! Check out these books, if you want to learn x86 asm yourself:

PCasm , WikiBooks , How Computers Work , and the usual Art Of Assembly

Initially I thought assembly was very different than it actually is.. It is, in fact, an extremely useful tool- but a very tedious tool. You can do amazing things with it, and any programmer with any credibility should read it!


Wednesday, November 30, 2011

Code!

Well it's long past due, it's time some programming. This one happens to be on computer networking! Whooo! You'll also get my NetworkingFunctions header- so pay attention, you may just get your mind blown(probably not)



I've attempted to keep my networking headers as simple as possible, and I think I've achieved that. However the biggest hole currently is the error checking, it doesn't give you a description of what's gone wrong, instead it just tells you something is wrong and expects you to investigate.


Essentials

In it's simplest form, a (TCP) socket is like a phone, what is said on one end is received on the other, and vice versa, however you can only talk to one person at a time on a single telephone, so additional telephones are required for more connections

a (UDP) socket on the other hand is like a public meeting, you're shouting out all of your information and anyone can pick it up and claim it, but you can direct your speech to particular people.

In both cases it's very possible for people to listen in on your conversations, so be careful with what you put out there =]

My Library(term used loosely, as it's not packaged)

For my library, to get two people connected, simply have one call auto_connect and the other connect_to, the format is something like this:

///Client int sock = connect_to("127.0.0.1",9999); //assuming you're connecting to self bsend(sock,"herro"); ///Server int sock = auto_connect_on_port(9999); string input = brecv(sock);


This simple functionality is all you need to get up and running with networking, and it's about all I've used for several large projects.


Monday, November 28, 2011

The journey to getting paid for applications!

I'm finding the road lengthening behind me, and shortening in my view. Finished several key components along the path and tasting the sweet victory of small accomplishments.



I've been working on an android application to forward SMS/MMS (text and picture messages for the layman) to and from a computer. So far we've got sms completely done, and I'm on the road to MMS. At one point what I thought may very well be impossible is proving to be not only possible but downright easy!

As for my opinions on Java, the language. Don't ask.


As for the rest of my projects, ubiquitous advances are being made in the realms of the iPhone as well as le OpenGL(3D&&2D). Projects, Screenshots, and Videos will be posted forthwith.

Wednesday, November 2, 2011

HOly FailTrain!

I am the worst blogger... ever!

Sorry! But I've been super busy!

While I've been gone I've:
-Made another game engine
-Started, and Quit a job as a technician and network administrator
-Finished countless work related c++ projects
-Started Learning Java and C#
-Learned enough OpenGL to make some games with it
-Made an awesome sidescrolling game as well as a tic-tac-toe and a pong game
-Gotten less terrible at SC2
-Finished "iPhone Programming, the Big Nerd Ranch Guide"
-Had an awesome time!

My Current Projects:
-iPhone block avoidance game [started 11/1]
-Block::Warrior (sidescrolling multiplayer shooter game) [started 10/5]
-A bunch of work-related mundane stuff =]

Here are some screenshots (videos to hopefully follow)


I've been lucky enough to have a lot of time to program lately and my code is getting pretty awesome. Collisions,events,animations,particles,sounds,text, and just about everything one needs for a game are now included in my engine.

Haha, also have a new favorite joke:
How many apples grow on trees? (see end of blog post for answer)

I've been slowly going insane trying to come up with playable games and not taking on any project that I won't finish, but it's going really well. I'll post a link to my game soon here (hopefully, you know I'm forgetful, so please email me and remind me! (seriously ... I'm so lonely... so... so.... lonely... (mr lonely starts playing in the background))

A little bit about block::warrior
It's currently in the stage of creation where one can create full levels and play around with them, if any of you are good at level design, please let me know. Because I suck. Badly. And no one wants that. Do they? =]



Oh and for you code junkies out there, here's my quick inventory system:

class inventory: public object{ protected: map types; vector numbers; public: int type_index(const string& type); int add_thing(const string& type, int number = 1); int remove_thing(const string& type, int number = 1); int get_number_of_things(const string& type); int handle_event(event* evnt); }; int inventory::type_index(const string& type){ if (types.count(type)) return (*types.find(type)).second; types[type]=numbers.size(); numbers.push_back(0); return numbers.size()-1; } int inventory::add_thing(const string& type, int number){ return (numbers[type_index(type)]+=number); } int inventory::remove_thing(const string& type, int number){ if ( numbers[type_index(type)]-number>=0) return (numbers[type_index(type)]-=number); numbers[type_index(type)]=0; return 0; } int inventory::get_number_of_things(const string& type){ return numbers[type_index(type)]; } int inventory::handle_event(event* evnt){ if (evnt->type=="getitem"){ add_thing(evnt->command,evnt->value); } }



(answer to joke) All of them! =]

Monday, April 18, 2011

Hey You Amazing Person!!

If you are reading this, pat yourself on the back, you are absolutely astounding.

This is just a quick update, I've gotten myself a menial job, 9-5 and as such my development time allotment has gone from 10-18 hours a day to < 3 hours a day... However! I will continue my work on everything, but at a furious pace (and attempt to keep up the pace) My app (CleanChat) is done, the server ... not so done. When the app is done, I'll spend some time making some tutorials on networking, collision detection/resolution, game engine design, and anything else requested or to be requested! So REQUEST STUFF

That is all.

Saturday, April 16, 2011

Thread Pool

Today, I've spent some time working on a little thing called a "thread pool". (Sounds like heaven for felines..)


*groan

A thread pool is essentially an expanding and contracting group of worker threads in a program to perform actions required by another thread. In my case these threads are going to do the work of receiving and sending to and from users of my iPhone app: CleanChat.

Right now I've begun work on a simple version with a static number of threads. It's horribly inefficient, but it's cool!!!

--------------------------------

Here's some code:
///WORKER THREAD/// void WINAPI thread (threadpool &pool){ threadpool* permpool = &pool; dispair a; //dispair is a pair of ints, it's a simple struct int nojob = 0; int jobnum = 0; char buf[255] = {NULL}; while(1){ int nbytes = 0; if (permpool->getjob(a)){ cout << "\nGOT A JOB"; if (a.one == -1) continue; if ((nbytes = recv(a.one, buf, sizeof buf, 0)) <= 0) { permpool->sockbroke(a.one); continue; } else{ if (a.two == -1){ permpool->addunconnected(a.two); } int tempgot = 0; while(nbytes > 0){ if ((tempgot = send(a.two,buf,sizeof buf, 0) <= 0)){ permpool->sockbroke(a.two); break; } nbytes -= tempgot; tempgot = 0; } } jobnum++; } else{ Sleep(5); nojob++; } } }

What is this? ... it's a mess, that's about it.

All this worker thread does is poll our thread pool manager, asking for a job, when it gets one (in the form of a pair of ints) it receives whatever info is available on the first int (which is a socket) and sends it to the second.

This is just a simple prototype, when I get the full working code, I'll post a tutorial here.

On another note: I may begin work on a network chess game, if anyone is interested in helping, or you just want to bug me, send me an email @ ultifinitus@gmail.com

Friday, April 15, 2011

String Permutation.

I Have Been Working On This Forever

First: String permutation is finding every possible combination of the letters in a string. For example:

-----------
string = "abc"

permutations:

abc
acb
bac
bca
cab
cba
----------

I have had a ton of fun with this, essentially I knew there were solutions available, and I'm sure there are a lot of better solutions as well. However, here's what I came up with.



Step 1. Write a function to swap two characters.
Step 2. Write a recursive function to return all permutations of a given string. It will call itself (minus the) first letter.





-1-

string getstringwithswappedchars(int first, int second, string toswap){ char buf = toswap[first]; toswap[first] = toswap[second]; toswap[second] = buf; return toswap; }

-2-

I was lying in bed, attempting to sleep, and *pop* I knew how to do it! My solution is essentially this. Take the previous call in the recursive loop (down to one letter which shall return itself) append the current letter to each, then add yourself to a vector after switching the current letter with every single letter in each permutation. beautiful
vector <string> permute(string toperm){ cout << "\npermuting " << toperm; vector toret; if (toperm.size() <= 1){ toret.push_back(toperm); return toret; } vector tvect = permute(toperm.substr(1,toperm.size()-1)); for (int b = 0; b < tvect.size(); b++){ for (int a = 0; a < toperm.size(); a++){ toret.push_back(getstringwithswappedchars(0,a,toperm[0] + tvect[b])); } } return toret; }