Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Tuesday, 3 March 2015

The Weasel and the Woodpecker

So far this week, I've drawn about three cartoons and written a Windows program to record all my cartoon submissions. Not that I've submitted many this week -- four or five went to The Spectator yesterday -- but the program is central to my vow to take my cartooning more seriously. My problem is that I've never been much of a 'submitter' and, as they say, you have to play the game to stand a chance of winning a prize.

When the program is completely finished, I might upload it here for free for anybody who might want to use it but even as I type that I have my monetary angel is banging his head against my right shoulder as if to tell me to stop being so damn generous. But, frankly, I don't think there are enough cartoonists or writers in the world who would want to buy it or even would find a need for it. The main reason I've written it is to also help archive my cartoons. I lose too many to computer glitches that I'm trying to make more use of online storage. So, every time I finish a cartoon, I add it to the database which archives a copy to Dropbox. With all my cartoons listed, I can (for the moment 'in theory') simply click a button and generate an email based on the publisher details I've already entered and with the cartoons embedded into the email.

When it's finished, I might give it away, might keep it for myself or I'll ask a few dollars for a copy and stick it over on The Digital Nib. Unlike my previous program, The Gag Machine, this isn't a long term project. It's more of a useful tool I needed and realised I could program in a day. And I did program its basic functionality inside a day. I was writing it when my laptop died on Sunday.

The loss of the laptop has be surprisingly hard. The faded/yellowed/'cooked' label on the back would say I've had the laptop about four years but for about three of those years, I've not switched it on for fear that it would burn out. However, since my writing my 'review' and claiming that I'd never use it again, I'd started to use a thermal cooler beneath the laptop. It didn't do a great deal but it did make it usable for short periods. With a slightly cooler lap, I'd started to use the laptop at least once a day and I'd got it just how I wanted it. I was programming more. Writing more. And then, within about two weeks, it has died with an inevitable smell of burnt solder. It died exactly how it died the first time it blew its video card. I now hate Dell with a passion. That laptop cost me so much to buy, thinking that buying from the XPS range would make it a long term laptop, only to have it now burn out twice. Only this time I've not asked for a repair. I'm not investing another penny into that machine or that company. The XPS 1340 was a horrible machine that should never have gone to market.

I should really get a new (non-Dell) laptop but they're so damn pricey and my attempts to monetise the blog have come to naught. I started my new drive to earn from blogging on the 4th February. It's now the 3rd of March and in one month I've managed to raise a whopping £1.06. That's £1.06 reward for 12 cartoons, 2 Photoshops and 21,000 words. Okay, that's not one of my most productive months but it's surely worth more than £1.06.

I'm not pleading poverty here (though, perhaps, I guess I am) but this is a example of the new internet economy in which the big guys make millions while the rest of us scramble around to earn pennies. The reality is probably that I should really blog less and devote my time to selling my cartoons or my software. It's galling that I think that but even more galling that my past efforts have come to naught. Take this morning's cartoon as an example. If I type 'George Galloway cartoon' into Google, one of mine appears at the top of the search results. That's even before you go into Google image search.




That's really weird and yet deeply satisfying.

The three other cartoons are by heroes of mine: Peter Brookes and Martin Rowson. My cartoon (below top) was drawn years ago when I was first starting out. I don't think it's anywhere as good as today's (below bottom) Galloway cartoon which, I hope, is not as good as the next one I draw.




Yet the cartoon is there. Multiply all those years of effort and count up the many hundreds of cartoons I've drawn, hundreds of thousands of words (I once calculated millions for all the blogs I've written), all of which is still online: and all I have to show for that this month is £1.06.

Forgive me if I sound cynical about the internet. The truth, for me at least, is that I draw a cartoon which hardly anybody looks at whilst Twitter is today dominated by a picture of a woodpecker carrying a weasel on its back. And if a woodpecker carrying a weasel isn't a metaphor for the great democratization of media production then I don't know what is.

Monday, 3 November 2014

Under The Rock

Woke up dreading the coming day. Not that I have anything out of the ordinary to do but the game being live makes me uneasy. I had a restless night, wondering about how it's performed. I always feel like this when something I've poured my heart into is suddenly out there. I just want to crawl under a rock and not look how my work is faring. I guess I'm not really suited to the harsh reality of internet life. I appreciate the good people enormously and it's why I do this. I feel lifted by every generous comment and email.

Good people make me feel better about the world and I know there are plenty of good people out there. I've been very blessed in my time as a blogger to have contact with many bright, encouraging, enthusiastic, and generous souls. I've also had the misfortune of attracting the scorn of a few whose vengeful ugliness really breaks my spirits. There really are too many Welsh Rottweilers in the world.

The outcome of yesterday was my releasing version 1.0.1 of the game. I'm taking an ambitious approach to my version numbers. The first 1 represents major alterations to the game. So, if I add a new big exciting feature, such as a new game mode, that number will increase to 2. The 0 will only increase when I add smaller but key features, such as new menu options or I fix some large bug. Last night I increased the last number, from a 0 to a 1 since I fixed a small but dumb mistake I'd made, positioning an important button in the space occupied by the ads. That last number represents everyday bug fixes. I expect it to get into double figures very quickly, possibly by early afternoon...

The other outcome of day 1 was my first look at my advertising stats. The numbers were higher than expected (due entirely to Tim Worstall, many thanks Tim)  but the income depressingly oval shaped. I don't understand it but I hope it will increase in the coming days and weeks. I never did this to make a fortune. It's more about achieving a goal and raising my competence as a programmer. However, I'd like to think that I'd get money for allowing people to paste their ads on my game. At the moment, if feels like I'm providing a charitable service to billionaires.

I'm honestly at a loss as to what to do next. I had a report from Barman who says that it's too difficult to throw the pucks the length of the board. I now have to go through my code very carefully, trying to figure out if I've overlooked anything that would make the throw power device dependent. The two main things that change from device to device are screen resolution and processor speed. But since neither should affect my calculations, I can't see what it could be. I could increase the power of the throws by any amount I like but I've spent weeks carefully tuning them to a point which doesn't break the game's physics. Time in computer games is not linear but discrete. A moving object doesn't have every moment of its path calculated to an almost atomic scale. Like slowing down a movie, objects leap through space. In a physics simulation, the objects also leap through space (but, theoretically, the gaps are much smaller) and if they're moving quickly, they can simply leap through other objects because the computer never examined the time-frame where the two objects would have collided. Of course, there are ways to calculate these things more carefully but it requires so much more computer power that, in the context of a simple game, it's unworkable.

However, that's my day. Solving a problem which I'm not entirely sure how to solve.

I drew some cartoons last night but they're lousy.

I'm going to hide back under my rock.

Saturday, 1 November 2014

Shuffleboard King: Your New Must-Have Android Game



Well, here it is, the efforts of the past few months which I've given the catchy name: Shuffleboard King.

I'll probably regret this in the morning but I've now released my first game onto the Play Store (hopefully, it should appear here in the coming hours). I might have delayed more but I'm mentally and physically exhausted and this is a somewhat daunting moment and I just wanted out of the way so I can move on and improve the game.

What is Shuffleboard King? Well, it's the version of shuffleboard I wanted to make for myself and for my friends who regularly play shuffleboard on their tablets. The problem with current shuffleboard games is that they feel quite artificial to play. Their physics tend to feel and look quite scripted in that you throw a puck and the damn thing flies out of your hand in a perfect straight line. Even the best shuffleboard game out there feels like the computer is playing the game for you.

So, I thought I'd try to make a shuffleboard game myself and this is the result.
I'd like to say it was 'easy' but, in truth, there are many hundreds of hours of work in this and it's probably thousands of hours if I take into account the many months before I started, just to learn Unity and all the other packages I used in this game's creation.

The part I'm most proud about, I guess, is the version of Sjoelen included in the game.
I nearly released this a few weeks ago but at the last moment, I discovered Dutch Shuffle (called Sjoelen on the continent). I watched a few videos and got hooked on the gameplay. I also realised that I could add my own Sjoelen mode to Shuffleboard Kings using the code I'd already written and, an extra month of work later, I'd expanded my original three game modes to include a fourth.

Those 4 games are the traditional shuffleboard, Sjoelden (Dutch Shuffle), as well as two games of my own creation: Angleboard and Crossboard, which do pretty much as described. On Angleboard, you bounce your shuffle off a rail so you have to play around a 90 degree bend in the table . In Crossboard, you can throw your puck from one of four sides toward a target in the centre of the table.

There's a tournament mode, in which you play opponents who are increasingly difficult to beat. There's also a challenge mode in which you have to beat 50+ challenges, such as throwing the winning puck on a board already dominated by your opponent.

I know there'll be bugs, typos, and probably even the occasional glitch. Some I can't fix but are part of the Unity engine. Others, I'll work hard to eradicate in the coming months, should enough people actually play the game.

I hope you will take a chance and play the game and perhaps, if you do, you could tell me what you think in kind, even patronising, words.

Friday, 31 October 2014

Ready For The Play Store

Today might be the day. I've now played my game through from the beginning to the end so I know all the achievements are winnable. The major bugs are (hopefully) fixed, though I don't delude myself into believing that it's now completely bug free. Bug-free computer code is theoretically impossible. In fact, I'm pretty sure serious research goes into that very subject and nobody has yet established a way of ensuring that the almost infinite number of inputs going into a system will produce a finite set of predictable results. So, although the game plays okay, there's probably going to be some person who comes along and jams a thumb in a place where I never expected somebody to jam a thumb, producing some crazy results. If a company like Bungee can produce a million dollar game like Destiny, release it to the public, and then face the problems they've faced recently with people exploiting cheats to boost their statistics or, as one particularly clever soul did, discover a way of jumping up a cliff face in order to explore an area of the game that Bungee had yet to unlock, then I'm pretty sure I'm going to face a few headaches over the coming weeks as people tell me that my game throws a fit whenever they do X,Y, or Z.

The moment I stick it on the Play store, I'll be on here talking about it and no doubt boring you with videos about how I made it and things I've learned about Unity in the approximately two months (and two days) it's taken me to build it since I started coding on the 28th August.

My final jobs today are to do with the marketing. I've recorded some gameplay footage which I now have to edit into a short video to include with my Play Store listing and on the website I've built to advertise the game and provide contact details for all the complaints I expect to receive. Then I need to double check all my text for typos.

One final coding job might remain but that's based on a last minute decision I've yet to make. How much I want to annoy players to encourage them to buy the ad-free version? At the moment, I have ads at the top of the screen but I'm wondering if I should add some interstitials ads, which are the full screen ads that occasionally pop up during gameplay. I don't like them, I don't want to add them, but the game as it currently stands is perfectly playable with banner ads. In fact, it might be too playable with banner ads and banner ads are going to earn me so little that they might as well not be there. Interstitials would earn me more but, more importantly, would give people a reason for upgrading.

The alternative is to carry on coding once the free version is built. Once that's launched, I could branch off a paid-for version of the game and start adding features to it. Other game modes might make it more attractive. I don't know. Any thoughts or advice are, as always, very welcome.

 

Monday, 19 May 2014

Unity2D: Creating An Explosion Effect



A quick video I put together to show my workaround for the missing AddExplosionForce2D in the Unity engine. It’s probably of interest to nobody out there but it gives a good idea of how Unity works and the very basics of making things move around on the screen.

Saturday, 17 May 2014

Small Details

Writing this feels like I’m coming up for air.

I read an article somewhere the other day which suggested that it takes six months to develop even the simplest game. I’m not entirely sure that can be correct, but, perhaps taken as an average, it’s probably much closer to the truth than the fabled ‘couple of days’ it took the Flappy Bird genius to weave his magic.

At the other end of the genius scale where things don’t come easily and everything is a struggle, it only feels like I get closer to the end as I tick off the increasingly mundane tasks that dominate my ‘To Do ‘list. Beyond that, I spend most of my time fixing bugs and populating my levels with graphics. My problem goes back to the beginning when I didn’t so much design the game as start to play with Unity and a game gradually began to emerge. My game levels are potentially huge, though there are limitations which means not every square inch needs to be populated with landscape. I’m naturally reusing assets all the time but I need to break that up with unique graphics, which is where most of my efforts are not deployed.

The bug fixing takes the longest. A bug earlier in the week took two days to figure out but taught me an important lesson about the difference between Unity’s Awake() and Start() methods. Compared to that, coding new features is an absolute pleasure that rarely takes a very long.

The exception to that rule was the problem I faced creating explosions in my game. Having explosions came pretty late in the process and I thought it would be an easy thing to add. Unity has an AddExplosiveForce method  which you can add to game objects so they act as a bomb, pushing other objects away. However, Unity separates its 3D functionality from the 2D in an obvious way. If a method is designed for 2D games, it will have ‘2D’ appended to the end of the name. So, for example, there’s a RigidBody component, which makes a 3D game object respond to gravity and forces. There’s also a RigidBody2D component with does the same for 2D objects. AddExplosiveForce adds an explosive force to a 3D object and, as you’d guess, AddExplosiveForce2D would do the same for 2D objects.

Except Unity doesn’t currently have AddExplosiveForce2D which meant I had to write my own. It took a day but I solved the problem and my explosions are now working well, with sticks of dynamite even destroying other objects with a nice blast that radiates out. However, it’s an example of how I’m spending my days implementing features which are only a very small fraction of the finished game.

Not everything takes so long. I’d been putting off adding more online leaderboards to the game but I finished that just now, perhaps half an hour’s work to add 30 leaderboards, one for each level I’m currently planning to include in the finished game. I also finished adding the majority of my ‘achievements’ and they now stand around the fifty mark which means I’ll have to spend extra time checking that every one of them works, which means yet another game reset so I can play through it and unlock the achievements myself.

Even at this relatively late stage in the process, I’m learning new things. The surprising thing I’ve recently discovering is that it can be really small things that make a difference. Attention to detail is important. Just as a whim, I added a very small detail to the game about three days ago and it has completely changed the game’s dynamic for the better. It was an addition I made simply to add a little variety to the gameplay but it completely changed the way the game feels. The same is true of sound effects. I still have a few sound effects that don’t fit but those that do really make a difference.

In a way, I suppose all of this is my way of saying that ‘things are coming together’. As it stands, the game is pretty much finished in terms of the gameplay (though I constantly worry that there are times when the player doesn’t have enough to do). I have quite a bit of level design to complete, but that simply comes down to my finding the time to draw custom graphics for the different challenges. On top of that, there are things to write and I have to create some tutorial mode or, at the very least, provide instructions on how to play the game.

Then my final step will be to add some advertising, which I’ll do simply in the vague hope that it might earn me a few bob when others try this game. I don’t expect it to hang around on people’s smartphones and tablets for very long but I’d like to maximise whatever revenue I can generate. All this work should have a point and, I admit, at the moment, I fail to see what that point could be beyond my own amusement.

 

Friday, 21 February 2014

Android Programming: Day 2... (Yes, this blog post is really going to be that exciting!)

Sadly, there’s been no word from Joleen, she of the big boobs and even bigger butt, but I have managed to create a SQL database inside Android, so you needn’t be too downhearted.

[Counts to three before he opens his eyes and looks to see who’s left in the room…]

If you’re still reading, it means you’re one of the better few who are less interested in pornographic internet SPAM and more interested in a misguided dabbler’s attempts to wrap his brain around Javascript. How easy is it to develop an app to run in Android, you ask? I’d say surprisingly easy, though the Android SDK running on Eclipse does create a functioning ‘Hello world’ App for your as soon as you install it. So in that sense: it’s very easy. In some ways, it’s actually easier than developing software for the PC, especially if you have an Android device plugged into your machine. The updated app code runs straight on the device so you get fewer of those ‘bugger, I’ve just crashed my PC’ moments you get when developing things for the PC.

I started this little ‘project’ about two days ago and I already have an app which does quite a bit more than say ‘Hello world’ and it’s running on my old Android phone which has become my unofficial test bed. I also have it running on my tablet but since I use that almost constantly, it’s not as easy to keep it plugged into the PC and it won’t be until my new ultra-cheap-but-long micro-usb cables arrive from China.

I don’t exactly know why I’m writing an app except the other day I was searching for something to do a specific task related to my cartooning. Not being able to find anything suitable on the Play Store, I began to wonder how difficult it would be to simply write it myself. I used to program databases after I did my computer degree – which, I should add, taught me next to nothing about programming – and before that I’d been a complete computer junkie making simple games with even simpler graphics. Every meaningful thing I’ve ever known about programming has been self-taught yet I’ve never truly taken the time to learn Object Orientated programming and what little I know about Javascript is based on my somewhat limited knowledge of C. I am an old school programmer completely out of his depth with newer code. In the past, I’ve often written simple things to run inside a web browser, to change the various random phases on this blog, for example, but I’ve always wanted to know how to develop a proper app. My cartooning hasn’t been going so well – no bugger seems to ever like anything I draw – and my writing is at a standstill given that the agent still hasn’t replied yet it’s probably a little too soon to send the book elsewhere. My enthusiasm for blogging is also at a new low and my ‘real’ work is just destroying my will to live. What better time to add another string to my bow?

The last couple of days have been about information overload and absorbing as much as I can. I’ve been selectively reading chunks from different huge tomes on Javascript written by clever people who don’t know how to write. That’s not to say that they’re incapable of writing but they’re incapable of writing for the audience to which the book has been marketed. The best I’ve found so far is ‘Android Apps for Absolute Beginners’ by Wallace Jackson, which has become my new Bible and I’ve read from cover to cover. Last night I also attempted Jeff “JavaJeff” Friesen’s ‘Learn Java for Android Developers’, which I thought I didn’t necessarily need but hoped it might help me remember the stuff I’ve long forgotten. About half way through an early chapter, I fell asleep and woke up to realise that I didn’t have a clue what he was talking about. Only a few pages earlier, I’d been told how to declare a variable and then I was suddenly deep into the murky territory of inheritance, polymorphism, and upcasting.
Following the cast, the contract’s reflexivity, symmetry, and transitivity requirements are met by only allowing Points to be compared with other Points, via expression p.x == x && p.y == y.

Sometimes clever folk need somebody a lot less clever to put a hand on their shoulder when they get excited and ask them to rephrase that for people without a doctorate in abstract logic. Of course, the fault might well be my own. I’m a terrible student since I never attempt the examples they write in the course of these books. I always want to get to the meat of the business. I get frustrated having to read five pages about how to change the colour of text, which is the sort of thing I tend to figure out quite easily. More difficult for me was learning how to open new screens from the main screen. It was obvious in the end but it was the kind of top down structural approach to software development I really needed at the beginning. Had they said that an Android app is made up of many ‘Activities’ which are essentially concurrent and each declared in their own file, I might have had a better idea of what I was doing.

I don’t think learning things my way is necessarily bad. It forces me to have an active knowledge of real programming rather than the kind of passive knowledge you get by simply reading other people’s code. I believe writing is best learnt by writing and speaking a language best learnt by speaking a language. Programming is best learnt by getting the hardware to do what you want it to do. My app might not break any records and surprise people with its originality but it will do what I want it to do and that’s a better achievement than simply producing the same code as you could have downloaded from your tutor’s website.

At this point, my ‘App’ is like some kind of Texas Chainsaw hillbilly with pieces chopped from different places and stitched together. Yet it actually does what I wanted and I’m delighted it works. I only have one functioning button, a menu system which deletes the database and then restores it by reading in data from text files, and my Settings page only reports things about the database just to assure me that the database actually exists. I wasted three hours yesterday trying to figure out why my database wasn’t being created only to later discover that my database existed and was fully populated with fake data but my ‘checkDbExists’ routine was flawed.

Christ… Does anybody find this kind of rambling blog post interesting? I’m not bright enough to actually write a meaning post about Android programming but I’m too dumb to realise I should just shut up and get back to it.

Today I’d like to figure out how to open a file selection dialog to import and export data. Later, I’d like to allow them to modify records and then start extending the functionality to the actually things I’ll hopefully find useful.