Wednesday, May 4, 2011

Tuesday, May 3, 2011

Moving

I'm moving over to WordPress. Google is being a bitch by asking me for personal information, and if I do not hand it over, they won't let me use certain features which is pissing me off. So, WordPress: here I come!

Hardcore vs. Casual Gaming



He's hired.

Monday, May 2, 2011

C++ Replace String

void replace(string &str, string s1, string s2) {
  while (str.find(s1) != string::npos) {
    int pos = str.find(s1);
    str.insert(pos, s2);
    pos = str.find(s1);
    str.erase(pos, s1.length());
  }
}

Sunday, May 1, 2011

Natively Chatting

My Spanish teacher assigns us homework via a website called WordChamp. On this website, there's a feature that allows you to chat with someone in any language. One of the options for the language is English. So... would that count as learning? I'm curious to see if the person on the other end would believe me if I said scrumdiddlyumptious or supercalifragilisticexpialidocious were real words, though the latter is very much well-known, so it would be difficult to convince them.

Actually, any thing that can be said and has meaning is a word, whether it be an English word or not. For example, I could say, "This candy is benegratic," which could mean something that is good and pleasing, but it's not truly an English word (though it does use English prefixes and a suffix).

Don't Kill Me, Ahmad

Wednesday, April 27, 2011

Saturday, April 23, 2011

Sam


Design is subject to change. Copyright © 2011 to Badger Games. All rights reserved.

Friday, April 22, 2011

Writing to a File

Like any good programming language, C++ and Java have a feature that allows one to write to a file. Though I will only show you the basics, this code should be easy to implement into your code:

C++:

// you will need to check
// your flags if you do not see
// the file in the directory
#include <iostream>
#include <fstream>

using namespace std;

void write(string address, string str) {
  ofstream out(address.c_str());
  out << str;
  out.close();
}

Java:

// import java.io.*;

public void write(String filename, String str) {
  BufferedWriter out = null;
  try {
    out = new BufferedWriter(new FileWriter(filename));
    out.write(str);
    out.close();
  }
  catch (Exception e) {
    System.out.println("Error: "+e.getMessage());
  }
}

Thursday, April 21, 2011

Stupidity of the Console Wars





Shut the fuck up, fanboys. Go stick your head in some lava and let the true gamers play their games. That is all.

JavaScript Random Message

One thing great about JavaScript is that it can be easy to write code for. Unlike programming languages, scripting languages are designed to have less code due to download speeds. Instead of vectors and lists, JavaScript uses arrays for all lists, even when you need to add more indexes to the array:

var messages;
// create array
messages = new Array("Hello World!", "This is a test.", "Look Eddy! It moves and swears!", "Robert Kotick likes men.", "That is all.");

// OR

var num = 0;
messages[num++] = "Hello World!";
messages[num++] = "This is a test.";
messages[num++] = "Look Eddy! It moves and swears!";
messages[num++] = "Robert Kotick likes men.";
messages[num++] = "That is all.";

// get random element
var ele = messages[Math.floor(Math.random() * messages.length)];

Simply create the array and use the ele variable to grab a random value from said array. This could be useful for JavaScript games you might work on in the future and for a random message for a website, like at GoNintendo (except those messages are displayed using a server-side scripting language like PHP as opposed to a client-side scripting language like JavaScript).

This would take more source code in C++. However, C++ gives you more control over everything, and JavaScript, in this programmer's opinion, is a bit of a mess at times. Still, it's a good language to learn for beginners.

Also, pingas. That is all.

Wednesday, April 20, 2011

Status Update - Halberd


I might turn this into a series; I don't know just yet.

Sunday, April 17, 2011

Housepets! is Back

In case you didn't notice, the Housepets! feed was removed. For some reason, it started acting up. I don't know why, but I assume it was just a hiccup. I just bothered to re-add it.

Little Bit of Randomness

C++:

// it would be wise to seed in a different function
// srand(time(0));

int rand(int min, int max) {
  return (rand() % (max-min+1))+min;
}

Java:

public int rand(int min, int max) {
  return new java.util.Random().nextInt(max-min+1)+min;
}

JavaScript:

function rand(min, max) {
  return Math.floor(Math.random() * (max-min+1))+min;
}

In order to add a random decimal, you would need to divide the generated number by a certain succession of 10s and add it to the desired variable. Keep in mind these functions run off the pseudo-random algorithm on the running computer, so the results may vary. This is simply a simpler, faster, and efficient alternative than an external library.