Sunday, May 24, 2009

Banging my head against a wall....

So in the end, I did enjoy today - it reminded me of the Sunday Sessions I had last year when I spent whole Sundays coding my website (and being frustrated by CSS). This being said, there was a great deal of frustration and a few tears at the start - unfortunately GameMaker doesn't have as many extensive developer forums and blogs as CSS - when I kept hitting walls, I didn't have anywhere to really go to help me work out what I was doing wrong. I just had to keep tweaking things and trying my luck!

So I imported all of the images I whacked together yesterday - and had a good laugh at how GameMaker turned them into strange coloured boxy shapes :-) The Stink bug shape was probably the closest to the original shape in the end, but no matter - I know a lot more will be better conveyed by moving and animated shapes, but I'm a long way off it really mattering with still so much work to do on the core mechanics!

After completing the tutorials yesterday, I felt I had a good handle on GameMaker and how I was going to approach this exercise. As it turns out, there's a canyon between understanding how to use it and gettign it to do what you want! I quickly realised, if you just built a fairly basic, standard game, a variation on something that existed (that there was a tutorial for!) it would seriously be a piece of cake - GameMaker is actually pretty esy to use - until you deviate from the basic set up and need to make it do something else - then there's a great deal of nutting things out and trial and error.

So, I built a room 480h x 1920w. The ground is made of sand tiles and the background is sky tiles that came with GameMaker. I used two wood tiles on either end as fence posts. They aren't solid, and more as a visual marker for players to know its the end of the field of play. I also plotted the 8 tree trunks as background - i wanted them fixed and as they wouldn't be involved in any action, I thought it would be best to leave them out of the objects folder.

I started by creating the bug and tryign to get it to fly around. i just programmed each of the keyboard arrow directions to move forward 4, whihc gives it a nice smooth movement, and allows for diagonal travel if two buttons are pressed at the same time. So the control system, that I thought woudl be the biggest issue to sort out, turned out to be the easiest! I set the room view to follow the bug so it pretty much stays in the centre of teh room until you get to either end of the field of play.

Next, I tried inserting the trees and oranges. Then I took it back to trying to just deal with one tree and one orange! i had a lot of trouble trying to work out how to get the bug to pick up the points from the orange. I set a variable orange_health at the creation of the orange (10). I tried setting it so when the x y coordinates of the bug matched those of the orange, it would set off the point transfer one point at a time (where it checked if orange_health >1). When orange_health = 0, the orange disappeared. At first this didn't even work, then I changed it so the sprites weren't checked for the precision collision thing, and that helped. Plus I made sure the entire image was included in the border. That worked, but you still had to line it all up carefully for it to work, which was much more fiddly than I wanted.

Then I discovered the question events - I got the bug to test when it was in contact with an orange and it did it easily! Too easily! I went back and scaled down the hit area in the sprites, and it all worked fine. So, next I tried to get the orange to regenerate. I managed to get it to work when I set it so when orange health = 0, the instance was destroyed, zzz for 1000 milliseconds, then create a new orange instance. The good thing was, after a lot of playing around with the variables and reading tutorial instructions and the GameMaker manual, I worked out how to get the oranges to appear randomly on the tree (obj_tree1.x+random(155) which is half the width of the tree area, and set up a similar thing for the height of the tree). I then needed a bigger sleep gap as i didn't want the orange to reappear that quickly - but when i extended the sleep duration, the whole game slept and that wouldn't work! I tried to set it up as: when orange_health= 0, instance was destroyed, then set off Alarm 0 in 120 steps (with Alarm 0 = crate new orange instance). That just didn't work at all. I didn't know what the hell was going on, so I thought I'd leave it and move on to the farmer.

So I set up the farmer to run left to right, turning at the ends, and at random(500) turning into farmerspray (when it stops and sprays the trees with bug spray) then turning back into the farmer, running in a random left/right direction. The random framer spray worked fine, but then it kept getting stuck as farmerSpray. So I thought - there's a pattern here - the alarm is working for my moving objects, but not for my still objects! I was either doing something wrong, it was a bug or a timeline issue. I tried the internet and the help manuals but couldn't find a fix or other people with the same problem. So I thought it might be a problem with the time getting stuck as without movement, the timeline lags (there's sometimes a sound issue in Flash - you have to set a dummy sound in the background at 0db to set the pace of the piece and keep everything on time - I thought it might be a similar problems, so I tried setting an invisible moving object and giving the still objects a horizontal motion (with 0 speed), but that didn't work. Then i had another look at how I had the alarms set up - for the FarmerSpray i had it in a step event, which was completely freaking it out, which made sense once I read about what a step event did (ie actions at every step!). Once I moved it to the create event, it all worked perfectly. So I went back to look at the space bar event (for the orange health drain). I realised that by not including a creation event before closing the brackets on the destroy instance event, the alarm in that bracket never played, therefore the orange just wasn't getting created!. I didn't want to try to set up the orange there as I needed the alarm set up to give it the time gap, so i created a controller_orange invisible object, which on creation set off an alarm that then created an orange, at the random tree location!

The sun was ready to set at this point and I couldn't believe how little I'd managed to achieve in a day - I honestly thought I'd have a complete prototype ready for playtesting, but it looks like I'll have to revise the timeline...

Anyway, the good thing was, by working this out on one tree, I was easily able to set up a test function that would count oranges - if there were n oranges at any point, the tree object and all controller oranges would be destroyed, which was a fundamental part of my sustainable game concept. i rolled this out to the other trees by duplicating the tree, orange and controller orange objects for the 8 trees, each with a separate test function for presence of obj_orange...obj_orange8. It was a lengthy way to do it, and there's probably nice elegant coding version fix for this, but it works perfectly. Lets just hope there's not only 12 alarms in total that you can use in a game, because mine are already all gone, and I'll have to go back and rewrite things if that's the case!

The I added the bug spray object separately, set off by the farmerSpray object. It stuck around for 4 seconds (the farmer ran off at 3 seconds). I tried to set up a collision event, but had to change it so the spray disappeared on collision, as rather than just -20 points per bug collision, it drained 20 points per step that the bug was in contact with it! As far as I can tell there's no timed option i.. every second 20 points gets drained, although maybe I can align that with the number of steps instead? If I have time later, I'll check...

So I started on the bird and checked out drawing a path, but I'm not sure how to get the bird to launch down the path and if i can get it so the path shape starts at random(room_width) or if it's set and I have to create a stack of paths. Alternatively I'll set up a path that just goes in a wavy horizontal line across the page and let the bird traverse along there in random direction. That might make it a bit less random (I'm aware I'm setting a lot of random parameters and I don't want it all arbitrary for the player!). I tried looking at the timeline, but couldn't work out ho to get it to work - need to spend more time checking it out as an option...

I stuck the scoreboard on there but didn't actually set it up to work. I tried to get the health option and score functioning, bu need it to be displayed to work out if the points tracking is working properly (including taxing 0.1 heath point per step, just for flying?). Also need to find out how to stick the scoreboard at the top of the moving room. I'm pretty sure the scrolling game tutorial covered a lot of these, need to go back and work through it again.

I think that's it for now? It was a whole day of fiddling and trying different things, so obviously a lot more than this was attempted, but that's all i can recall!

So, re my prototype, I have:
  • the first level room background completed (which could be used in each level with the most minor of adjustments)
  • The bug is flying and eating oranges.
  • The oranges are functioning as they should
  • Trees are functioning as they should
  • Farmer is functioning as it should
  • Bug spray is working
I still need:
  • Stink bombs
  • the bird - path, launch, interactions, sound
  • scoreboard set up and fix in place
  • health drain for being alive
  • sounds for everything and proper graphics
  • tweak the orange recreation timing once the health drain is set
  • bonus oranges and stink bomb awards
  • if you start eating an orange, you need to eat it or it dies? without that, the hidden bonus orange concept is lost. Maybe make them short lived bonus oranges that appear with a chime for 10 secs?
  • Then I need to create other levels, extra lives etc. As the time thing isn't feasible, I'll have to make it a score based level advancement
The worst thing is, I can't do this tomorrow - I have two other assignments I need to focus on instead. The Tuesday I have classes all day. I really need to close myself...

No comments:

Post a Comment