|
Post by melonzgz on Apr 29, 2016 20:26:14 GMT 1
I really like this one Cute graphics there...
|
|
|
Post by wonder on Apr 30, 2016 2:38:09 GMT 1
Come on, Andy... It's time for a video teaser!
|
|
|
Post by andymc on May 3, 2016 7:38:24 GMT 1
A video will come soon, but probably not till the end of the week. right now I have all the graphics loading in, the level loads in correctly but there's no code for moving anything around so that's the task for this week. Hopefully by the end of this week I will have the enemy soldiers showing, have the players soldiers moving when you tap the screen, and possibly be able to shoot at the enemy soldiers, but this bit will work differently to the PC version so may take some time to figure out. I'm thinking how to handle collision detection right now, the blitzbasic language on the PC gave me pixel perfect collision detection for free, but I don't have this with Libgdx, so I could either us my own detection routines based on distance, or redo most of the game So I'll use distance based detection.
Apart from the enemy bits, what's next on the task list? I've got to check that loading the level collision map has wored correctly, it's a 666 by 666 2D array, it's very inefficient to use a 2D integer array to hold values between 0 and 3, so I'm going to change it to a 1 dimensional byte array and use each byte to store 4 2 bit values, this should mean that instead of using a 666x666=443556*4bytes=1.7 mbs ram, I can do it in 443556/4=108kb using my new format. So by switching from a 2D integer array to a a 1D byte array and storing 4 values in each byte, then I can do the collision map using only 108kb of RAM! So I save 94% of the space. Which is brilliant! It will also make my datafiles much smaller too, right now each level has a 300kb collision file attached to it.
Anyway, enough of that, as you can see I'm trying to do as much of this on my own as I can, I know there are tile map modules for Libgdx I could use, and the box2D stuff might make my explosions work better, but I think that you learn a lot by writing this stuff yourself. If I ever make a sequel to this, then that can use better physics and sprite atlases (and anything else I can think of), it already has a long feature list to write, but need to get this one finished first!
sorry if these entries get a bit technical, I use them as a way to sort my thoughts on things. I will show off more of the game when I've got something good to show. Right now I've just realise I need to write soem custom functions for drawing the graphcis as blitzbasic drew everything with the coords being the centre of the graphic and not the bottom left as it is with libgdx, so need to sort that.
|
|
|
Post by ilan on May 4, 2016 7:58:08 GMT 1
Looks very nice, andy. About the collision detecting. Since you are using an isometric design i would suggest you to use a grid map to store all position of the trees and soldiers like this you dont need to check floats u just check cell index. Like a 2d array of x and y. And each cell has an index. So now u just update the index of the soldiers and always check if this soldier has a neighbor next to it like a tree and then you dont let him jump to the next cell U can use this technic but u dont have to move the characters with the cell width you can move them in smaller steps but they will move to the next cell center (like in chess) I made a random maze generator that use that algorithm. Take a look at it. If u need the code i will send it to u b4x.com/android/forum/threads/random-maze-generator.66465/
|
|
|
Post by andymc on May 4, 2016 9:09:51 GMT 1
thanks for the suggestion ilan, I will look at it.
these sort of problems are what makes writing games really enjoyable for me. Like getting on screen controls working without resorting to using a prebuild library. My game won't look amazing, but it will have lots of technical challenges for me to complete.
The main game loop aside from drawing the game is 860 lines of code, which has to deal with which direction each soldier should be looking in depending on whether he's shooting, walking, or just standing still, how grenades should act (as I'm not using a physics engine), how bullets upddate and check for collisions (which I'll need to write my own routine for), and everything else. It's great fun working on this but I wish I had more time to do it!
If this game does well (more than 5000 downloads) then I will work on a sequel. And if it makes any good money then I'll get an artist to redo all the graphics to make it look much better.
|
|
|
Post by andymc on May 4, 2016 11:18:10 GMT 1
DON'T GET EXCITED!
Here's a very quick video showing the level drawn out, scrolling around using my finger, and the men going through a simple animation cycle.
The next video will show player movement and collision detection. Probably on Friday.
|
|
|
Post by andymc on May 4, 2016 14:16:25 GMT 1
Jsut to show what needs updating for each frame of the gameloop, here's the basic loop from the PC version, this will be pretty much the same in the Android version:
'adjust mission timer 'check inputs - done 'update grunts - done 'update weapon variables - done 'update grunt position - done 'stop if destination reached - done 'check for collisions - done 'fire at enemies if left unattended 'point grunt in right direction if firing 'kill grunt if dead 'check for picking up crates - done 'check for picking up health packs - done 'check for picking up airstrike packs - done 'update landmines 'update prisoners 'update good bullets - done 'check if bullet in playing area 'check for enemy collision - done 'check for huts 'check colarray - done 'update alerts 'update grenades - alter blitz code to add bounce and delay before explosion 'update rockets 'position 'collision with enemies 'collision with huts 'check for huts 'update enemy grunts 'kill if dead - done 'move towards good grunts if within range 'fire at good grunt 'check for alerts 'collision with huts 'colarray 'update enemy bullets 'check if within playing area 'check good grunts 'check huts 'update raindrops 'update snowflakes 'update particles 'update birds 'update explosions 'update airstrikes 'update airstike bombs 'update huts 'hut strength 'update rescued text boxes 'play bird sounds 'check ambient background noise 'calculate logic time
Most of the work should just be converting the code across, I will make improvements where I can for efficiency and bug fixes, but it should be very quick to copy the code over and get something showing more than just scrolling around. The next target is to get the collision map working and have soldiers walking around when I tap the screen.
|
|
|
Post by andymc on May 5, 2016 8:15:02 GMT 1
Thursday 5th May update: I have managed to get the men moving around the screen when you tap anywhere. They don't point in the right direction yet (that's tomorrows job) but they do move. I had a problem where the Y coords on libgdx were opposite so the men kept moving up rather than down. Feels good to actually have some interaction with the game.
|
|
|
Post by andymc on May 6, 2016 7:53:59 GMT 1
The men now look where they're walking! I only had one difficulty, but then I realised my old code worked in degrees where as B4A works in radians natively, a quick conversion back to degrees has resolved that issue.
Next task is collision detection to pick up items. The issue here is I don't have pixel perfect collision detection, so I have to use a function to calculate the distance between my soldier and the crate, then pick up the crate if the distance is less than a certain amount, I'll play with the amounts till I find one that feels right. Okay, that's done, crates get picked up now. I've also now added bombpack pickups and healthpacks. These do update variables showing each solders health and weapon counts, but these numbers aren't displayed on screen yet, that's a later task.
For now, I'll post a video of how it looks.
the next task after this, at the start of next week is adding in bullets and shooting at enemies. I also want to alter the view code to automatically scroll the view based on the direction the soldiers are moving, right now you drag the view with your finger which I don't like. I also need to change the soldier movement code so that the second solider follows the first as right now they kind of move together and merge which looks terrible.
|
|
|
Post by wonder on May 9, 2016 20:13:31 GMT 1
In the video, I can see that some of the soldiers are being drawn over the trees. I assume you have no DrawOrder sorting algorithm implemented yet. When the time comes, create either a List (slower) or a 2D-Array (faster) that holds a reference to each GameObject alongside with its Y-coordinate. Sort the data structure by Y-Coordinate, 1 time per cycle, and draw in that order. Something like this: '*** THIS IS NOT REAL B4A CODE ***
'At the initialization code. For Each obj As MyGameObject in AllOfMyGameObjects DrawingOrderArray.Add(obj, obj.position_y) Next
...
'At LG_Render DrawingOrderArray.SortBy(obj.position_y) 'Remember to sort OUTSIDE the For loop For i = 0 to (DrawingOrderArray.Size - 1) Dim MyObj() = DrawingOrder.Get(i) DrawObject(MyObj(0)) Next
'*** THIS IS NOT REAL B4A CODE ***
|
|
|
Post by andymc on May 10, 2016 9:07:07 GMT 1
good idea Wonder, thanks for the suggestion, that is something I need to look into. Right now I just draw things in an order thatmakes it look like ordering except for when the soldiers walk in front of things, then you notice it like you have.
|
|
|
Post by andymc on May 10, 2016 9:16:52 GMT 1
10th May Update: You can now shoot at enemies and kill them! I have implemented firing at enemies, when an enemy is tapped, if the distance to the enemy is short enough, then the soldier will fire at the enemy, the code is written in a way that the bullet fires at the enemy even if they are moving, I will add a graphic to highlight the enemy being targeted. But currently bullets will be generated, the positions are updated and collisions with enemies are checked based on distance to enemy location and bullet location, so I will need to tweak this a little to make it look as accurate as possible. When an enemy is killed, the enemy is removed from the enemies list, the players grunt kill count is increased (as each bullet has an owner assigned so each soldier can have a kill count which contributes towards rank promotions), the bullet is then removed form the bullets list. So playing the game, you can run around, shoot enemies, move onto the next one and kill him.
Next job is to make enemies fire back and move. I will follow normal game rules and have enemies move slower than the players soldiers and fire less often. I also need to alter the players bullets to be less accurate, this is simple to do by just adding a random amount o the angle of fire calculated which will get more accurate as the players soldier increases in rank.
|
|
|
Post by andymc on May 12, 2016 9:03:39 GMT 1
Gahh!!! I'm trying to get the screen to move in relation to the directon you move your men, but it's going all crazy! Basically I'm setting the destination screen offset numbers to be a multiple of the mvoement amounts on the x and y axis for the lead soldier, so if he's pointing directly right, then the screenoffset will be 500 pixels to the right and 0 pixels up or down from his position. The offset values for the view should then accelarate smoothly to move the view over and stop when the destination coords are met. But it's not working like that, right now the screen moves upa nd down as expected but has a (rubbe band effect that I can't figure out, and when I move right, the screen moves left until the game crashes. I think I'll start from scratch and just try to get left and right working before worrying about up and down. Also, maybe I don't need the screen destination to update every time the soldier is updated (every frame), maybe if I make it once a second, then it'll work much smoother. I also need to figure out out how to slow down the view rather than just stop dead. I should have an hour or two this evening to look at this and will hopefully crack it then. Then I can look at getting the men to look in the direction they're firing when they're moving, and also getting he enemies to do something.
|
|
|
Post by andymc on May 12, 2016 13:56:57 GMT 1
Okay, I've managed to get it working during my lunch hour, it's a bit clunky the way I've done it, and I'd like to improve it if I can, but it works for playing the game, so I'll leave it as it is for now then come back to it later.
Now I have to decide whether to get the enemies moving next, or to get the second player soldier following the first, probably the second first, then the enemies. I can then start implementing the particle system for blood splatters on bullet impacts, tighten up the collision detection and add in the dead enemy grunts sprites. I'm also adding muzzle flashes and a glow effect to bullets too. Once this is done I'll make another video, that will probably be tomorrow night, I hope to get two or three hours work done on this tomorrow. Then maybe another hour on Saturday morning.
|
|
|
Post by andymc on May 13, 2016 8:47:40 GMT 1
I managed to find some time yesterday evening to work on the second soldier following the first. I use a list of coordinate objects, the coordinates just hold the x and y values of the position and the angle the soldier is looking at, every time the lead soldier moves, the current position get's added to the list with the direction he's currently looking in. Once this list gets to 50 values long, then the second soldier is updated each frame to the values at the 50th place in the list to mirror what the first soldier was doing 50 frames ago that he was moving, the list is only updated when the lead soldier moves so the second soldier stops moving when the first solider stops without bumping into the back of him. this has meant re-structuring a lot of the code, as the main update loop was designed to go through both soldiers and update them one after the other, but now only the position of the second solider is updated, so he's not animated when he walks and doesn't interact with the environment, like picking up crates or shooting at enemies, he's like a ghost following the first guy right now. So I'll need to re-write the code to update both soldiers when shooting at enemies so everything works right, I might also decrease the list length, as 50 updates behind seems a bit far, it's like he's 20 feet behind the first guy and I think they need to be a little tighter than that. This conversion to Android is good fun though, and I'm able to make a lot of improvements like having real alpha values on textures and rotate sprites in real time, I'm also fixing lots of issues the original PC game had and making it play much better. Currently it plays at full speed on all my devices and actually plays too fast on genymotion (not sure why), so not worried about performance yet, but this may be something I come back to later.
|
|