Showing posts with label link. Show all posts
Showing posts with label link. Show all posts

Monday, 20 July 2015

Opening new tabs with Dojo, Ajax and Safari on iPad

Recently found out that Safari won't call window.open() in a callback when using dojo.xhrPost and dojo.xhrGet. This is a false positive with the popup blocker. The pop up blocker is usually a good thing, so we don't want to just tell the user to disable it. We need another way to get around this.

Spent a good amount of time finding the answer to this, so figured I'd re-post it in case someone else has the same troubles.

For reference, I needed to do this as the page I wanted to open wouldn't be available until after a server hit was processed. Here's what I had.

dojo.xhrGet({
    url: some/url.html,
    load: function(){
        window.open('some/other/url.html');
    }
}); 

Without boring you with the details, the solution was to move the window.open() call out of the callback and then hold the window reference in a variation so that the window location could be updated after the server hit.

var winRef = window.open(); 
dojo.xhrGet({ 
    url: some/url.html,
    load: function(){
        winRef.location = 'some/other/url.html';
    }
});

Big thanks to Jens Arps for the solution to this issue.

Wednesday, 3 September 2014

Apache Server Permission Error

Every single time I create a new apache server I forget to give permissions to the www-data group. So I'm pasting a great answer I got from stackoverflow to this blog for future reference.

//Create new group
$ sudo addgroup webdev

//Change the group of your web directory:
$ sudo chgrp -R webdev /var/www/
$ sudo chmod -R g+rw /var/www/

//Set the guid bit on all folders in your web directory:
$ sudo find /var/www -type d -exec chmod +s {} \;

//Add Apache to the webdev group:
$ sudo usermod -a -G webdev www-data

//Add your user to the webdev group:
$ sudo usermod -a -G webdev <user_name>

Hopefully this helps someone

Saturday, 11 June 2011

Hackers Unite

So, we have all heard about Anonymous; (in)famous for a number of hacks. Well, it seems like they are going to stage a revolution. See the Youtube channel, or the blog for more information. Looks like this is going to be big. 

For those of you with any coding knowledge, go the EnigmaGroup. Test and train your skills. Become the best you can be. Keep information free. Keep in contact. Keep life interesting. Hack the planet. 

If you haven't already, watch Hackers. Above is wallpaper.

When you register, don't forget that Milk referred you. The site has various training missions that simulate hacks. All you get is the site/page to hack and a description of the mission. That's it. The rest you need to figure out on your own.


Protips - Chrome does some weird things when it loads a page that makes the javascript console not get elements from the web document properly. Use Firefox and get Firebug. Linux is also pro, but don't bother unless you are getting serious.

I will be posting some information regarding the missions on EnigmaGroup. Don't just go to the forum to find the answers, they aren't there anyway. You need to use the internet. Find the answers. Coding is 10% knowledge and 90% Google.

tl;dr - Safe site that hosts hacking tests and missions for beginners to experts. Now, you want to read it all, huh?

Wednesday, 25 May 2011

Two Apocalypses Down, One To Go

The forecasts for the beginning of this century were quite ominous. Firstly the Y2K bug, then the Rapture, and then the End of the World.

Does anyone know what the Y2K bug actually was? Basically, computers were not future proofed and so only stored 2 numbers of the year, so 91 or 99, and simply prefixed 19 whenever asked. So the thought was that when the clocks ticked over to the year 2000, all computers what see the time as 1900, but wait, computers weren't around then! And so the computer would have a melt-down, or explode, or attack humanity.


Microsoft actually released a patch to prevent this apocalypse so luckily we were all saved. It must also be noted that a 32 bit date system used in Unix systems will have the same effect as returning to epoc time, but that is due to happen 2038.

The most recent apocalypse happened 21st May 2011, at 6pm EDT. Missed that one? Me too. A large community of the Christian faith believed that the second coming of Jesus would occour that day. Apocalypse 2011 it seemed, was a slight miscalculation. So how did this date even come about?
Wikipedia has this to say:

In 1970, Camping dated the Great Flood to 4990 BC.[26] Using this date, taking the statement in Genesis 7:4 ("Seven days from now I will send rain on the earth") to be a prediction of the end of the world, and combining it with 2 Peter 3:8 ("With the Lord a day is like a thousand years, and a thousand years are like a day"), Camping concluded that the end of the world would occur in 2011, 7000 years from 4990 BC.[8] Camping takes the 17th day of the second month mentioned in Genesis 7:11 to be May 21, and hence predicts the rapture to occur on this date.

Sounds like reason enough for me, but nothing happened, so what now?

On May 23, 2011, Harold Camping stated that May 21 had been a "spiritual" Judgment Day and that the Rapture will occur on October 21, 2011, together with the destruction of the world.[22]

So we are still awaiting the death and destruction all of man kind. Fan-fucking-tastic.


Next up, if we survive the physical rapture, is the Mayan worlds end prediction. These have been justified using mostly astrological alignments and the end of a calender created thousands of years ago.


Since this theory took off there have been numerous different theories on what will cause the end of the world. None of which have any real credit to them, as far as I am aware.

So that's my rant.
I posted a message on the  Apocalypse 2011 website and am hoping that it makes it past the moderation. I doubt it. Though I did leave a link to my blog and so if anyone has ended up here from there, feel free to leave a message. I will only remove content if the post is excessively vulgar, but it will still show that a post was made.

Cheers,
Milk

Wednesday, 4 May 2011

C Four, miGame, Part 2

I've noticed a lot of searches hitting my blog with my C Four program I made, here. So I'm going to go into a bit of depth about the game now. A lot of the searches say 'Program that proves Connect 4 is a draw'. This got me curious.


Wikipedia says "The game was solved mathematically by James D. Allen (Oct 1, 1988), and independently by Victor Allis (Oct 16, 1988). With perfect play, the first player can force a win by starting in the middle column. By starting in the two adjacent columns, the first player allows the second player to reach a draw; by starting with the four outer columns, the first player allows the second player to force a win."
It also has a couple links to freeware you can download that plays the perfect game. But I'd rather solve it myself.

Lulz


Initial thoughts: So we know the concept, get four in a row either diagonally, horizontally or vertically. The board is 7 long and 6 high. This means that we must use the middle column to get a diagonal or horizontal win. Also a diagonal or vertical win needs the two middle rows. As the board is filled row by row, it become immediately clear that middle board dominance is essential.

More lulz


Could do: I know how to model turn based games on a graph with nodes representing game state and then use logic to determine from what states a player can force a win. But that's boring and very time consuming to do by hand. See xkcd has done this for tic-tac-toe.

Will do: So what I'm going to do instead is alter my old version of C Four (get it? Connect Four but it's written in C so I called it C Four...) and create an AI that uses a depth first recursive search to find the optimum position for the next piece. I could have it build a graph at run time and then traverse the graph with each move made but computers are fast enough to handle what I'm trying to achieve here.
Basic: Make a program that looks at every possible move and picks the best one. 


What I will need:
Time. I'm back from University holidays and my memory is terrible so will have to go back and learn C.
Visual Studio or something similar to develop in. I'm posting at work so will download this to my flash drive and play with the idea from there.
Money. Not for this project but it's always good to have money, am I right?

Even more lulz


Akin to my original C Four program the game is going to be in ASCII. If I am able I will keep C Four as it is and simply add the option to verse a computer player or even watch a computer player verse another computer player. This is where the money is at.

[Connect Flour image. Sorry I lost this one. But it is funny]

If it works correctly we should see the two computer players play the exact same game every time. And hopefully player 1 will always win. That would be pretty cool.

I'm going back into hospital tomorrow for my kidney stones again, but workload from University has lessened so will work on it in my downtime.

Cheers,

Thursday, 21 April 2011

I'm Sick

So guys guess what. I found out I have kidney stones in my right kidney. Spent a few days in and out of hospital over the last few weeks for this. Worst pain I have ever felt in my life. Morphine and all the good stuff was administered. Basically, it is what it sounds like. I have formed rocks in my kidneys. My guess is that it was the 2+ Mothers a day I was drinking.

Mother-energy-drink-Australia.JPG

They are like V / Monster / Red Bull / Demon, (I don't know what other countries have), but they have the maximum legal limit of caffeine and all that good shit. Limit one 500 mL can per day. Felt great. Kept me going well.

Needless to say I had a range side-effects from the green including: chest pains, eye and arm twitching, and greenish coloured urine... I have since stopped having energy drinks...

Here is a picture of some kidney stones.



Not fun. Mine is 6mm, which means it's on the line of too big to pee out, so they are going to blast it with ultrasound to break it up so that I can pee it out. Beautiful. In the meantime they have put a stent in me.



So it has one curly end in my kidney and another curly end in my bladder. This was inserted through 'existing entry points'. That is to say, men, you do not ever want to have to get one of these... Luckily I was under general anaesthesia, or I would have died from fear.



Ultrasound blasting thing is 5th May and then getting the stent removed sometime after that. I'll keep you posted.

It's been 4 days since the stent was inserted and normal bodily function has resumed.

I have a whole bunch of boring university work going on at the moment as well so I'll have to wait until something exciting comes up before I have another decent software related post. Will probably put up one of the personas our group made for one of our projects later on. It looked pretty cool.

Oh and Portal 2 anyone???


Comes out in New Zealand TODAY on Xbox 360. Does anyone know if you can play split-screen local co-op on the Xbox? PLEASE let me know.
Cheers,
Milk

Tuesday, 8 March 2011

miTanks, Part 10

It's not working... I've been trying different ways to get the game to draw to screen though I just don't have it working yet. Fixed a couple minor bugs, as I hadn't moved everything across from the PC version.

When running I follow the debug and step through the program. Turns out the game runs perfectly, that is the game constructs and plays out completely with two random computer players, except it never draws to the screen. Thought the onDraw(Canvas canvas) method would be called automatically every couple of milliseconds. Turns out no. So, I need a way to get the canvas (i.e. the screen) so that I can call the method myself. Working on it...

If anyone knows how android views work, let me know...

As for sounds, I have this site that generates old school game noises. So I'll probably use that for my sounds. Means I don't have to search for people to make decent sounds. Lol. Sorry to those of you that did help with that. There just weren't enough to continue with them.

So the site looks like this:



Here is the link. Will probably be my one stop shop for sounds in the future. Check it out.

My roommate made me a little icon for the game as well. His tanks looks better than the little ones I made in the last post. So may end up replacing them with copies of his. I'll post the icon when I have my computer again.

Cheers,
Milk

Saturday, 5 March 2011

miTanks, Part 9

That's right! miTanks is back. After a very very long break I've got motivated to finish it. Or at least get it on the platform it was originally for. Haven't really had much commitment from Foo, which is both our faults really. I'm not the best teacher and he has little / no coding experience. And lobbing him with graphics was not the best move.

Sorry to everyone that doesn't have an Android, but you can still enjoy my struggle with xml and the Android graphics classes... And the PC version will still have the same look and feel as the Android version, with the obvious touch-screen exception.

Can't remember if I've said already or not but this is a fantastic, simple example of how to make a game on Android. The game is open source so I'm basing the majority of figuring out how to do graphics on this. For those of you know don't know software programming is basically: "Learn the basics; google the rest."


Image courtesy of xkcd.

I think I have a pretty good idea of what I need to do now. The tanks are going to look something like this:
 

And the turrets are just going to be a black smooth edged square, pointing at whatever angle they need to. The ground is either going to be a solid colour or each pixel will be 1 of three colours. This will depend on how much time it takes up to search and utilise a very very large 2D colour array.

I'll be using the sky square (not a box, it's 2D) Foo created earlier, because it is awesome. This will be the background of most of the levels. Might end up overlaying some objects like a building or something.




What else? Damage isn't quite right. The tank only takes damage if the very centre is hit. Not a major flaw but not very ascetically pleasing.

I'll get to work on this all tonight and post something on Monday(?) about what I have done.

Links to the other miTanks posts:
Part 1, The Plan
Part 2, Initial Concept
Part 3, Object Oriented Design + Update
Part 4, Sound Request + Update
Part 5, First Screenshots
Part 6, Ground Types
Part 7, Weapons + Ground Dynamics
Part 8, Initial Release

The last one contains the initial release for PC. Have a look at that if you haven't already. Just renamed all my posts... I had two part 4's AND 2 part 6's. That's just bad...

And as always suggestions are always appreciated.

Cheers,
Milk

Friday, 4 March 2011

Internet Game / General Update

So I've started back at University this week. It's pretty boring so far. Seems that a lot of the code writing stuff is going to happen later on. Which is gay. It means no exciting content for this blog for a wee while.

Also I have recently moved house, which means I can only get online at University, and so haven't been on the blog or anything exciting for a while. Should have internets by next week though.

Supposed to be learning about networking this semester so hopefully, I should have a nice network game to stick on here for you all. That would be awesome.

Something fun:
Has anyone tried to play QWOP? You are Qwop, our small nation's sole representative at the Olympic Games. Ideally you will run 100m but our training program was under-funded. Remember, it's not about whether you win or lose.

Basically you have four buttons, Q, W, O, and P, with which you control the runners thighs and calves to make him run 100m. Sounds easy right? Shit no!

Woo! Straight away instead of running, I decide to do a backflip... Not good. After a decent amount of gameplay my record is 5.5m. Good job Qwop.

Thursday, 24 February 2011

Top 50 Video Game Characters of All Time

I found this on stuff. Thought it looked about right. Shows the characters first appearance in brackets.

What do you guys think?

Link to article.

1. Mario (Donkey Kong, Nintendo, 1981)    2. Link (The Legend of Zelda, Nintendo, 1986)
   3. Master Chief (Halo: Combat Evolved, Microsoft, 2001)
   4. Solid Snake (Metal Gear, Konami, 1987)
   5. Cloud Strife (Final Fantasy VII, Square, 1997)
   6. Pac-Man (Pac-Man, Namco, 1980)
   7. Lara Croft (Tomb Raider, Eidos 1996)
   8. Gordon Freeman (Half-Life, Valve, 1998)
   9. Kratos (God of War, Sony, 2005)
  10. Sonic (Sonic the Hedgehog, Sega, 1990)
  11. Crash (Crash Bandicoot, Sony, 1996)
  12. "Soap" MacTavish (Call of Duty 4: Modern Warfare, Activision, 2007)
  13. Nico Bellic (Grand Theft Auto IV, Rockstar, 2008)
  14. Samus Aran (Metroid, Nintendo 1986)
  15. Ratchet (Ratchet & Clank, Sony, 2002)
  16. Nathan Drake (Uncharted: Drake's Fortune, Sony, 2007)
  17. Captain Price (Call of Duty 4: Modern Warfare, Activision, 2007)
  18. Kirby (Kirby's Dream Land, Nintendo, 1992)
  19. Marcus Fenix (Gears of War, Microsoft, 2006)
  20. Pikachu (Pokemon Red/Green, Nintendo 1996)
  21. Yoshi (Super Mario World, Nintendo, 1990)
  22. "CJ" Johnson (Grand Theft Auto: San Andreas, Rockstar, 2004)
  23. Mega Man (Mega Man, Capcom, 1987)
  24. Sam Fisher (Tom Clancy's Splinter Cell, Ubisoft, 2002)
  25. Shadow (Sonic Adventure 2, Sega, 2001)
  26. Jak (Jak and Daxter: The Precursor Legacy, Sony, 2001)
  27. Duke Nukem (Duke Nukem, Apogee, 1991)
  28. Dante (Devil May Cry, Bandai, 2003)
  29. Naruto (Naruto: Konoha Ninpoch, Bandai, 2003)
  30. Altair (Assassin's Creed, Ubisoft, 2007)
  31. Zelda (The Legend of Zelda, Nintendo, 1986)
  32. Sephiroth (Final Fantasy VII, Square, 1997)
  33. Donkey Kong (Donkey Kong, Nintendo, 1981)
  34. The Prince (Prince of Persia, Broderbund, 1989)
  35. Ezio (Assassin's Creed II, Ubisoft, 2009)
  36. Leon S (Biohazard/ Resident Evil, Capcom, 1996)
  37. Ash Ketchum (Pokemon Red/Green, Nintendo, 1996)
  38. Guybrush Threepwood (The Secret of Monkey Island, LucasArts, 1990)
  39. Spyro (Spyro the Dragon, Universal, 1998)
  40. "Ghost" Riley (Call of Duty: Modern Warfare II, Activision, 2009)
  41. Goku (Dragon Daihikyoe, Epoch, 1987)
  42. Max Payne (Max Payne, Rockstar, 2001)
  43. Jill Valentine (Biohazard/ Resident Evil, Capcom, 1996)
  44. Princess Peach (Super Mario Bros., Nintendo, 1985)
  45. Larry Laffer (Leisure Suit Larry in the Land of the Lounge Lizards, Sierra, 1987)
  46. Augustus Cole (Gears of War, Microsoft, 2006)
  47. Bowser (Super Mario Bros, Nintendo, 1985)
  48. Eddie Riggs (Brutal Legend, EA, 2009)
  49. Ryu (Street Fighter, Capcom, 1987)
  50. Sackboy (LittleBigPlanet, Sony, 2008)

Thursday, 17 February 2011

miMTGCrawler

So as per my previous post, I have written a very simple program to show me the value of Magic Cards. All you do is run the program and type in the name of the card. Then it prints out the value of the card for each version it is in. In addition it also saves and formats the printed bits in a txt file, which is compatable with spreadsheet software. See images below.

Simply type in the card you are looking for and press enter.


That is then saved here.


Which you can then import...



Here!


It also takes into account cards that do not exist. But not half typed. i.e. If I typed 'myr' it would return everything with myr in the title... No really worth fixing. More the error / aid of the website it's searching.

[Small error fixed: 'Mirrodin Besieged Singles' was picked up from the ads on the side bar. Now the first category is correct. I'm not replacing the screenshots though. You get the picture. (Spot the pun)]

Code below:

#!C:/Program Files/Python/Python 2.7

import urllib

print "miMTGCrawler version 0.1"

f = open('cardList.txt', 'a')

# The below URL is the link to a card. The card name is appended, also '+' replaces ' '. Case is irrelevent.
# e.g. 'Myr Enforcer' = 'Myr+Enforcer'
# Searches the website starcitygames.com for the information.
scLink = 'http://sales.starcitygames.com/search.php?substring='

while(True):
    print "Please enter card name: "
    card = raw_input()
    if card == 'q':
        break
   
    #Builds the URL for the card.
    cardLink = scLink + card.replace(' ', '+')
    page = urllib.urlopen(cardLink).read()
   
    # Search for the category. e.g. 'Mirridon'
    categoryString = 'http://sales.starcitygames.com//category.php?cat='
   
    # Jumps to the first listing.
    pos = page.find('tooltip')
       
    pos = page.find(categoryString, pos)
    # Loops through this process until there are no more valid categories on the page.
    while (pos != -1):
        pos = page.find('>', pos) + 1
        # This will build a string for the Card and it's categories and values of the listing found.
        cardString = card + '\t' + page[pos : page.find('<', pos)] + '\t'
        pos = page.find('">$', pos)
        # Checks to see if a price was found following the category.
        if pos == -1:
            print 'There is no such card: ' + card
            break
        cardString = cardString + page[page.find('$', pos) : page.find('</td>', pos)]
        print cardString + '\n'
        f.write(cardString + '\n')
        # Look for the next category.
        pos = page.find(categoryString, pos)

      

Back With a Plan

I'm back. Fiji was awesome. Got a wee bit burnt... But no visible tan due to the copious amounts of sunblock I was applying. Damn. Also I left the sunblock at home so never found out about taking it through customs. Crystal clear water and fish everywhere. Also a lot of frogs. I found that strange. I don't have the camera with me at the moment so pictures will have to wait. Though they will be on here at some point.

As for tanks: No progress. Aside from the visuals there isn't too much to do (that is fun to code). So I'll have a chat with Foo to see where we are heading with this and will let you know.

In the mean time. I did come home to a large amount of Magic Cards at the door. I'm not expecting to use them all, large is an entire shoe box full which I got for NZD$10.50, so I going to try to make some of my money back by reselling them individually on TradeMe.

I'm not a hardcore fan so I have little to no idea of the worth of the cards, so what I am going to do is write another web crawler, like this one. Woo! Finally back to some coding. This is going to search StarCity for each card and return the value of said card for me, then dump it into a txt file; which I can directly import to a spreadsheet. Should let me know the most valuable to least.

I'm going to be using Python for this. Will post the source later on Ok? Ok.

Tuesday, 18 January 2011

C Four, Connect Four, miGame

I'm taking a break from miTanks for a while. Here's one of my first ever programs.

I spend alot of my time in lectures at University playing Connect Four on a piece of paper against friends. This is the best paper game we could come up with. Turn based, so could simply pass notes or signal which column to drop in. And there was no need for an eraser; imaging trying to play chess with a pen.

At the time we were learning C programming and had to come up with some simple program to prove we learnt something in the course. Alot of people went with a Facebook similar 'What animal are you?' kind of game. Boring!



It took about 2-3 hours. Remember this was my first C program I created purely by myself, aside from Visual Basic and MicroWorlds (if that even counts).

Code:

#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
//C(onnect) Four
//Created by: Milk
//Date of final build: 19/10/09
//Height of each line
#define LINE_HEIGHT 6
#define LINE_WIDTH 7
void DrawBoard(int grid[LINE_HEIGHT][LINE_WIDTH]);
int CalculateWin(int grid[LINE_HEIGHT][LINE_WIDTH], int player);
int ValidInput(int input, int grid[LINE_HEIGHT][LINE_WIDTH]);
int main(void)
{
 //Plays connect four
 int grid[LINE_HEIGHT][LINE_WIDTH] = {0};
 int gameOver = 0;
 int input = 0;
 int player = 1;
 char inputValid;
 int i;

 //Draw the intitial board (empty)
 DrawBoard(grid);
 while (gameOver == 0 && (grid[LINE_HEIGHT - 1][0] == 0 || grid[LINE_HEIGHT - 1][1] == 0 || grid[LINE_HEIGHT - 1][2] == 0 || grid[LINE_HEIGHT - 1][3] == 0 || grid[LINE_HEIGHT - 1][4] == 0 || grid[LINE_HEIGHT - 1][5] == 0 || grid[LINE_HEIGHT - 1][6] == 0)) {
  //Get input from user
  input = 0;
  printf("\nWhere would you like to go, player %d?\n", player);
  scanf("%d", &input);
  //Decide if input is a valid move
  inputValid = ValidInput(input, grid);
  //If input is not valid prompt for a valid move
  while (inputValid == 0) {
   printf("Please choose a valid position: ");
   scanf("%d", &input);
   inputValid = ValidInput(input, grid);
  }
  //Add input to grid
  for (i = 0; i < LINE_WIDTH; i++) {
   if (grid[i][input - 1] == 0) {
    grid[i][input - 1] = player;
    break;
   }
  }
  //Draw the board
  DrawBoard(grid);
  //Calculate if there is a win
  gameOver = CalculateWin(grid, player);
  //Set the next players turn
  if (player == 1) {
   player = 2;
  } else {
   player = 1;
  }
 }
 //Print winner
 if (gameOver == 0) {
  printf("\n\nThere are no more available moves!\nIt's a draw\n");
 } else {
  printf("\n\nCongratulations player %d!\nYou won\n", gameOver);
 }
 return 0;
}
void DrawBoard(int grid[LINE_HEIGHT][LINE_WIDTH])
{
 //Draws the board
 int i, j;
 printf("\n\n\n\n\n");
 for (i = LINE_HEIGHT - 1; i >= 0; i--) {
  printf("\nI");
  for (j = 0; j < LINE_WIDTH; j++) {
   if (grid[i][j] == 0) {
    printf("   I");
   } else if (grid[i][j] == 1) {
    printf(" X I");
   } else {
    printf(" O I");
   }
  }
 }
 printf("\n__1___2___3___4___5___6___7__");
 return;
}
int ValidInput(int input, int grid[LINE_HEIGHT][LINE_WIDTH])
{
 //Calculate if input is valid
 if (input < 0 || input > 8 || grid[LINE_HEIGHT - 1][input - 1] != 0) {
  return 0;
 } else {
  return 1;
 }
}
int CalculateWin(int grid[LINE_HEIGHT][LINE_WIDTH], int player)
{
 int i, j;
 //Calculate if there is a win on the horizontal
 for (j = 0; j < LINE_WIDTH - 3; j++) {
  for (i = 0; i < LINE_HEIGHT; i++) {
   if (grid[i][j] == grid[i][j + 1] && grid[i][j] == grid[i][j + 2] && grid[i][j] == grid[i][j + 3] && grid[i][j] != 0) {
    return player;
   }
  }
 }
 //Calculate if there is a vertical win
 for (i = 0; i < LINE_HEIGHT - 3; i++) {
  for (j = 0; j < LINE_WIDTH; j++) {
   if (grid[i][j] == grid[i + 1][j] && grid[i][j] == grid[i + 2][j] && grid[i][j] == grid[i + 3][j] && grid[i][j] != 0) {
    return player;
   }
  }
 }
 //Calculate if there is a diagonal up-right win
 for (i = 0; i < LINE_HEIGHT - 3; i++) {
  for (j = 0; j < LINE_WIDTH - 3; j++) {
   if (grid[i][j] == grid[i + 1][j + 1] && grid[i][j] == grid[i + 2][j + 2] && grid[i][j] == grid[i + 3][j + 3] && grid[i][j] != 0) {
    return player;
   }
  }
 }
 //Calculate if there is a diagonal up-left win
 for (i = 0; i < LINE_HEIGHT - 3; i++) {
  for (j = LINE_WIDTH - 1; j >= 0; j--) {
   if (grid[i][j] == grid[i + 1][j - 1] && grid[i][j] == grid[i + 2][j - 2] && grid[i][j] == grid[i + 3][j - 3] && grid[i][j] != 0) {
    return player;
   }
  }
 }
 //No win
 return 0;
}


When compiled the exe file is only 56.0KiB. So it's pretty much always on my USB drive now.
And here it is:
http://rapidshare.com/files/443141503/Connect4.txt
I don't think rapidshare likes exe files so once you download just change the file extension (txt) to exe, and it will work. Give it a go.

Looking back at this code there is not actually too many things I would do differently. Would've been a nice OO exercise though.

If anyone wants to give me a game just tell me your starting move. Let's play. Lol

Cheers,
Milk

Wednesday, 12 January 2011

QR and Google URL Shortener

Here is the QR code for http://screaminghawk.blogspot.com/. Android has an app that reads these barcodes and then takes you to the sites are adds the contact or whatever the information. Handly dandy ay.
I'm sure you all know TinyURL. Well now google has http://goo.gl/. Because this site is new the URL wills be even shorter. It also tracks page views etc. http://goo.gl/ZafRK = My blog. And then the QR code for that URL is even smaller.
To generate your own QR codes go here http://zxing.appspot.com/generator/. It's fantastico!

Friday, 7 January 2011

Post Your Blog Here!

I can't get on to see some of your guys blogs!
Post links to your blogs here.
I get alot of down time and it's good to see some new content.

Any other coders / gamers out there?

Wednesday, 5 January 2011

miTanks, Part 4

Happy New Year!

Hope everyone's holidays are going well. Nothing too exciting going on in mine. Had a nice few days off work for drinks and general relaxation. Didn't do too much on the tanks game but thought I should update what has been happening. Foo is currently on holidays afk so not much in the lines of GUI completed.

Sorry I don't have many pictures for this project. As the GUI is last on the TODO list, this will come when the app is in the testing phase. I'll get some code up here later on for you all aswell. As this uses Java classes the code is spread across multiple files. I'll upload any interesting code I make though. Have a couple little bits in mind for later on.

Completed:
More of the inner workings are completed for in game.
The game physics work.
(better now)
Simple flat terrain completed.
Support for differing gravity, wind and landscape. (three landscapes have been added, one fully completed)
Support for random terrain generator. (included in landscape)
Support for multiple weapons, including weapon movement and collision calculations.
One weapon implemented. (fully implemented, including circular proximity damage)
Multiple matches in a game. (support for)
Game cycle. (may need to be editted once visuals and sounds are added.)

Still to do:
Getting input. Once input can be received the usage is already implemented.
Tank movement.
Display. Location calculations implemented. Just need to know how to put an image on the screen.
AI calculations, of differing skill levels.
Perfect AI, should be easy to do.
Absolutely useless AI, is even easier.
Realistic AI is somewhat harder. Shouldn't take too long. I'd just fudge some numbers from the perfect AI.
Defensive weaponry support. Shields and such.

NOTE TO FOLLOWERS:
I'm going to need some sound effects for this game. Such as a tank moving sound, bullet fire sound, bullet fall, explosion, and probably some others. If you can link me some sounds you've made I'll give them a listen and add the best ones into the game.