View Full Version : tankwars kent sarikaya - kryton9
TankWars version 3.1
Adjusted the Red and Orange and added a few new colors. Think of Blue as night mode :)
Thanks to Petr for all his help and for Eros for giving us the fixes and additional requests for thinBasic.
The splash screen has the latest keyboard and gamepad control help.
This version brings a fun ai. The enemy do their patrols until you are in firing range. Then they turn and shot, if you go out of range they will go back to their patrol.
It is fun to tease the tanks this way to see them react. You can also hang at the edge of the range, let them fire and pull back, watch their shot blow up short, what a great feeling.
The game is set for medium difficulty, after a few games go for hardest and try to get a perfect game, that is take out all tanks with no hits on yours.
Good luck!!
Updated 2013: If version 3.1 gives an error then please download and use the fixed 3.2 version.
3.2 Version for thinBasic 1.8.9.0
ErosOlmi
30-05-2008, 07:36
ABSOLUTELY fantastic kent :o :o :o
A little more AI for the tanks and we can start ... selling games ;)
Wow, I wasn't expecting that. :o
You should upload some screenshots, I'm sure a lot more people would download the game if they could see how good it is.
ErosOlmi
30-05-2008, 08:11
Eros, I need a recap on passing udt's as parameters. I tried but failed in this version. More later, but you guys get the idea of what is coming at least with this.
Kent,
yes, there are some limitations on this area. For example it is still not possible to pass an UDT if it is an element of an array of UDT. Thanks for recalling this to me. I will work on this.
But you can pass a single UDT like the following example:
'---Define UDTs
type txyz
x as double
y as double
z as double
end type
type tplayer
id as string * 6
pos as txyz '--- position
rot as txyz '--- rotation
trg as txyz '--- target
dist as double '--- distance from player
near as long '--- id of nearest tank
move as double '--- move amount
turn as double '--- turn amount
range as double '--- range of fire
alive as long '--- alive or exists
time as double '--- time alive or other time stuff
name as string * 12
end type
'---Create some variables of that UDT
dim MyNewPlayer_1 as tPlayer
dim MyNewPlayer_2 as tPlayer
'---Pass your UDT to a general purpose init function
'---UDT passed as param are ALWAYS passed BYREF. It means a pointer to the
'---original UDT is passed. Changes done inside the sub/function are in reality
'---effecting the outside UDT
initplayer(MyNewPlayer_1, "AAA")
initplayer(MyNewPlayer_2, "BBB")
msgbox 0, _
"Player 1 ID is " & MyNewPlayer_1.id & $crlf & _
"Player 2 ID is " & MyNewPlayer_2.id & $crlf & _
""
'---Init a player
sub initplayer(APlayerToBeInit as tPlayer, PlayerID as string)
APlayerToBeInit.id = PlayerID
APlayerToBeInit.pos.x = 0
APlayerToBeInit.pos.y = RNDF(3, 3.25)
APlayerToBeInit.pos.z = 0
APlayerToBeInit.rot.x = 0
APlayerToBeInit.rot.y = 0
APlayerToBeInit.rot.z = 0
APlayerToBeInit.trg.x = 0
APlayerToBeInit.trg.y = 0
APlayerToBeInit.trg.z = -1000
APlayerToBeInit.move = 0.1
APlayerToBeInit.turn = 0.5
APlayerToBeInit.range = rndf(10, 100)
end sub
Thanks for the kind words guys, I was all excited yesterday about it and hoped to have it further along, but I hit a big wall today.
Your nice words are encouragement to keep working on it as a team now.
I wanted to share it and get input so that before it gets too complicated we can put in all the parts. Like the event manager,
and Charles's stuff, not sure which :)
I don't want to put screenshots yet as it is still not where I want it. It is more a demo to recruit you guys to join in.
I have lots of ideas for it, but it will get complicated and it needs to be well organized and get the above mentioned elements in place.
Thanks again for taking a look and kind words!!
Eros I logged onto post this example that doesn't work and see you replied back.
I will post it anyways. This does not work, would be nice to be able to do something like this in the future:)
'---+------------------------------------------------------+
'---| |
'---| warning: |
'---| |
'---| this crashes the computer |
'---| |
'---+------------------------------------------------------+
uses "console"
type txyz
x as double
y as double
z as double
end type
type tplayer
pos as txyz
rot as txyz
end type
dim p,e as tplayer
p.pos.x = 100
p.pos.y = 0
p.pos.z = 100
e.pos.x = 200
e.pos.y = 0
e.pos.z = 200
print "distance between player p and enemy e is : "+format$(distance( p.pos , e.pos ),"0.00")
console_waitkey
function distance( a as txyz, b as txyz)
local c as txyz
c.x = a.x - b.x
c.y = a.y - b.y
c.z = a.z - b.z
function = sqr( c.x * c.x , c.y * c.y , c.z * c.z )
end function
Petr Schreiber
30-05-2008, 10:13
Kent,
this is so professionally done retro, perfect-awesome-fantastic!
I could not believe my eyes, very cool!
Regarding the task you want to achieve ... pointers are programmers best friend :):
uses "console"
type txyz
x as double
y as double
z as double
end type
type tplayer
pos as txyz
rot as txyz
end type
dim p,e as tplayer
p.pos.x = 100
p.pos.y = 0
p.pos.z = 100
e.pos.x = 200
e.pos.y = 0
e.pos.z = 200
print ("distance between player p and enemy e is : "+format$(distance( varptr(p.pos) , varptr(e.pos)) ,"0.00"))
console_waitkey
function distance( ap as dword, bp as dword) as double
local a as txyz at ap
local b as txyz at bp
local c as txyz
c.x = a.x - b.x
c.y = a.y - b.y
c.z = a.z - b.z
function = sqr( c.x * c.x + c.y * c.y + c.z * c.z )
end function
Now please excuse me, I have tanks to blow up ;)
BIG thanks,
Petr
Petr, I split your version off into its own sticky and will sticky any others also as they are made.
Just put out a new update, added temporary sound for now. The latest version in is in the first post in this thread.
The Radar now has 3 levels of color indication.
Darkest Green tanks still alive
Medium Green the nearest tank
Bright Green the nearest tank is in range
Petr Schreiber
02-06-2008, 07:31
Thanks Kent,
the sounds fit it very well!
Petr
Thanks for help with Midi to get it going!
Version 1.7
Organized and cleaned up the code quite a bit.
Getting it ready for working on tank ai next.
Added a faint indicator on the radar to show range. This way you can see which tanks are in range and which aren't.
The highlighted tank is the one whose name and distance is given and is the nearest in distance to you.
Eventually you will be able to cycle amongst targets and get the info for that tank, who is in it, distance, health etc.
Still not quite a game, but it is getting close :)
The first post has the latest version
ErosOlmi
04-06-2008, 07:45
Thanks Kent.
This is becoming a real game.
Thanks Eros, Just uploaded a fix to 1.7
And also fixed the strange radar range shape it was bothering me. Turns out it is the aspect ratio of the screen.
Right now I set it to 1.5 and we have nice circular radar range indicator and the tank barrel in the radar is consistent now.
All little things that were bothering me, but finally getting resolved.
Now with cleaner code, can get onto more complicated things :)
Version 1.8 is now uploaded to the first post with these fixes.
Petr Schreiber
04-06-2008, 09:35
Thanks Kent,
very nice! What about using midi sound to get even better illusion of own tank movement ( like different sound played only when turning left/right, going forward/backward ).
Petr
Petr, better sound is down the list for now... i just wanted to get basics in while developing it.
Just put up a slight bug fix for 1.8 again, sorry about that, but better to have latest working up I believe.
Next on my list, now that the things that bothered me are taken care of... is working on tanks firing back :)
ErosOlmi
04-06-2008, 10:37
Kent,
this is the list of my request (sorry, for asking) for the moment ;D
use a triangle for our tank shape on radar so we can see our tank direction
as Petr suggested, some sounds for our tank moving could be more immersive. I will see what I can do with MID.
name of the opponent over the relevant tank written is a font size proportional with the distance (do not know if possible)
indication in the hud of where to go for the next target
Ciao
Eros
Thanks for thoughts and suggestions guys.
About sound, I am not spending anymore time on it as I want to use whatever Charles comes up with in the future for sound synthesis, instead of midi.
About triangle, Petr had it in his radar and it does point and look really well, but it reminds me more of something for a space game.
I wanted to keep my look more primitive. I did put the tank barrel as an indicator of direction. When I put in player option settings, maybe the player can make the size of this item to their taste.
I wanted to not use names over the tanks, thought seriously about it... want to make it work in the HUD, this I will fine tune over time.
An indicator of where to go... thought about this a lot too, again I feel that is more for something like a space of flight game where you need help. In this since it is slow moving and only left and right turning, I think the tuned radar should be good enough.
Right now it shows you only the nearest tank, eventually I want to give player the option to cycle through the tanks, to see who is where or have it auto do it for you as if the radar was sweeping. I want to keep it sort of like a real thing but obviously it is a sim in the look.
I am very excited you guys are thinking of things for it and am happy you share your thoughts. Over time I hope all of the things on your wish list will be answered. Right now I want to work towards my vision for the game. The tank ai to make it fun to play is in my thoughts.
Once I get the game the way I want and can say ok here is my presentation... then I will be very happy to help in making it fit the player's desires.
Thanks for feedback guys! It gives one energy to keep working.
Just to show I am not heartless :)
I did a minor update to the radar, it should be easier now to see which direction the tank is looking.
This will be the first of a bunch of 1.9 updates till version 2.0 which will have basic enemy ai.
Petr Schreiber
04-06-2008, 23:58
Thanks Kent,
the way you did the indicator reminds me of old classic game "F-29 Retaliator" ( or something like that ).
It was flight sim, but it had similar icon used for missiles on hud I think :)
Very nice,
Petr
Glad you liked the new indicator Petr, I think it suits the tank pretty well. It was on my mind for future improvement, but while I was thinking of ai, got it finished.
There is a bug in the game which will be addressed further down the line. When you move your tank in the z axis, the radar indicator for the shot does not match reality.
The aspect ratio adjustment is messing it up when I move the tank. I am aware of this bug, but it is not critical for now. The actual 3d world stuff works, it is when translating to 2d and adjusting for aspect that it only messes up in the game z but radar y values. I tried some quick solutions, but none worked.
Anyways onto the main topic now...
Petr, I think I know the answer, but I want to make sure with you first.
Ok, we have:
Begin Const
%TankFirst = 1
%TankLast = Game.NumTanks
%Tanks
%Player
%Light
%Level
%PlayerShot
%Reticle
%Explosion
End Const
But it gets really confusing when we add more elements as:
Begin Const
%TankFirst = 1
%TankLast = Game.NumTanks
%TankShotFirst
%TankShotLast = %TankLast + Game.NumTanks
%Tanks
%Player
%Light
%Level
%PlayerShot
%Reticle
%Explosion
End Const
Now you can imagine how confusing it gets when later on in the programs trying to do loops and when you create your arrays.
The Constants don't match the dimension of the arrays and you get all sorts of errors.
Right now the only solution I see is to keep offset variables for each entity that is an array, can you think of anything else?
So I would have an offset variable for any array entity after the first set:
%TankShotOffset = Game.NumTanks
Then when I loop the array of TankShots it would look like
For s = %TankShotFirst to %TankShotLast
TankShot(s-%TankShotOffset).Alive = 1
tbgl_EntitySetPos(%Game, s , TankShot(s-%TankShotOffset).Pos.x, TankShot(s-%TankShotOffset).Pos.y, TankShot(s-%TankShotOffset).Pos.z)
Next
Of this could also be written:
For s = %TankShotFirst to %TankShotLast
s = s - %TankShotOffset
TankShot(s).Alive = 1
tbgl_EntitySetPos(%Game, s + %TankShotOffset , TankShot(s).Pos.x, TankShot(s).Pos.y, TankShot(s).Pos.z)
Next
As you can see not the cleanest of solutions... just wanted to mention it to you so your super brain can work on it in the background till you find an amazing solution!
This is just to show why it won't be this way :)
This is if the enemy tanks had the same capabilities that we the player would have.
As you can see, it won't be any fun.
I just wanted to share this version, so when you do see how it is handled,
you won't wonder why I didn't do it this way :)
Don't set it to difficulty 8, it crashes the game... right now 7 of the 8 tanks fire in the same manner our tank does.
Same range and distance and ability to shoot. There is no collision tests for enemy shots at all. That will come later when I get a nice shot sequence that will be challenging but not crazy. But as you will see formations will be coming, so it should be pretty fun.
I removed this attachment as it is outdated now.
Thanks to Petr's help and great bug hunting abilities.
Here is pretty good early version of tanks shooting.
The major bugs seem fixed with the great help from Petr.
Not an official release till I add more to it to bring it to version 2.
Under the Radar there is a tank integrity read out and how many times you have been hit / max hits you can take.
Version 1.9.5 is in first post.
ErosOlmi
05-06-2008, 09:50
Great Kent!
I'm sorry I cannot contribute more on this project but it seems you are making great progression with this game.
Thanks Eros. You are contributing greatly by making thinBasic better and better each day!
I hope to make good progression today, that is all I dreamed about while sleeping :)
I'm having fun playing with AI tests today.
Right now, I have the enemy tanks fire only when they are in range to you. This way you know when you hear a shot, it was fired while the tank was in hitting range. Makes it much better already with that tweak alone.
The next thing I want to work on that is annoying me is that the tanks right now are always aiming at you. I am using the cool entity command for this:
TBGL_EntitySetTargetPos ... But it works too well:)
You never see the tanks from the sides as before when I had them turning. So I need to replace this with something where the tanks have to turn to find you and you see them turning. I think it is worth the effort to add this as it should make it more interesting visually.
Just wanted to keep you guys up to date on what is going on.
Well, Version 2.0 is here.
Major changes to it the last 2 days. Right now it is set on the easiest difficulty setting, but with the most tanks, 8.
You get lots of hits before you get killed, so it is easy and fun.
It is fun to just go in for a couple of minutes if you want to blow up some tanks and get fired upon. I want it to be a fun little break and not too hard of a game. I think it fits that with my tests.
I added gamepad support, the standard keys still work as before.
GamePad:
Button 2 Forward
Button 3 Backwards
Button 6 or 8 Fire
POVLeft Turn Left
POVRight Turn Right
You can go into the Input Subroutine if you want to change the gamepad settings for now.
Next on the list:
Splash Screen
Instructions
User Settings
More Formations
And Levels from easy to difficult depending on user's choices.
I need help on how to make it turn without using the target command in tbgl. Right now it is too perfect. Once I understand that, then hopefully you will see the tanks in different views than the almost constant head on view.
Enjoy!
ErosOlmi
06-06-2008, 07:24
This is a very good version Kent, very good.
Petr Schreiber
06-06-2008, 09:52
Thanks Kent,
very nice update!
Regarding turning ... I prepaired little concept for you, hope it will be usable for the project.
Petr
UPDATED VERSION > Smarter and correct turning
Thanks Petr, very nice example, it will really help add a better feel to the game!
I am very happy to announce that the new and vastly improved Tanks Wars is officially released.
This release makes it a complete game.
This release coming so soon is only possible with the tremendous amount of work Petr put in.
We will see some new commands soon in tbgl as a result of this project and also some updates as you might notice to thinBasic.
Thanks to Eros and Petr for bringing these changes so quickly and Petr for putting them into the game.
You will need the latest, I mean as of June 10, 2008 evening release of thinBasic.
Please download and enjoy. You can go into the options and adjust the game to make it super easy or challengingly fun.
Even if you lose, you get nice funny taunts from the enemy.
For the ultimate go for a perfect game and get the wonderful Flawless Victory.
Happy Gaming, a big thanks to Petr again for his help in busy times the last few days!
The latest is in the first post.
Petr Schreiber
11-06-2008, 00:22
Dont get the wrong impression :D,
Kent did lot of work on this. You will see there is noticable difference from last public version.
Petr
ErosOlmi
11-06-2008, 07:54
Really a complete game. Great job as usual, great team work. You have used a lot of the latest developed features. WITH/END WITH makes the code much better readable.
You are a battle team coding!!!
---
Now the dark side ;)
I've played a bit with TankWar and found strange results with enemy distance and my bullet distance calculation.
For example I have the enemy I want to hit listed in the upper left area at about 400 distance. I fire my bullet and it shows over 1000 (in the center HUD) and goes down while running to the target. Problem is that on the radar my bullet stop his running much before it goes near the target it was supposed to be at 400. If the bullet has a range of over 1000, how can it be? So seems something not in sync or I'm not understanding it in the right way.
What about a key that if pressed move the camera over my bullet when it goes on the target :D
It can be a firework effect :o
Ciao and thanks
Eros
Petr Schreiber
11-06-2008, 13:26
Hi Eros,
the distances on radar are in meters, while the number going down is lifetime of the shot in milliseconds.
The recalculation to distance is easy, will see what Kent will think about it.
Camera on shot sounds nice, maybe it could be done as nested viewport. Then you could drive the vehicle while controlling where shot flies :)
Petr
ErosOlmi
11-06-2008, 14:03
Ok, now I see. I didn't realize about distance in one case and time in the other.
Your idea about viewport is terrific and could have great visual impact !!!!
Maybe first time in a script?
Very happy you liked it Eros. Petr and I always ask ourselves will Eros like this, Petr usually replies, yes but we need blood :)
Petr's ideas for the game sound good to me. He is busy for a few more days and I am ready to take a break from tank wars after intense couple of weeks in it.
When Petr is finished with school finals, then we can put in the new suggestions, if that is ok with you guys.
ErosOlmi
12-06-2008, 07:38
Very happy you liked it Eros. Petr and I always ask ourselves will Eros like this, Petr usually replies, yes but we need blood :)
Petr knows me quite well now ;D
You already did a terrific job in this project. Some rest is merited!
Michael Hartlef
12-06-2008, 19:00
Nice game Kent. I see you put a lot of work into it. Thanks for sharing the script.
Thanks Mike. It would not be what it is without LOTS of help from Petr. I'm sorry I wasn't able to get TBEM into it as I had hoped. I wrote to Petr that I learned a lot about working on something like this in this go around. I thought do the hard stuff first and then add parts in, but it doesn't work well in reality that way.
My next go around is going to be the whole thing as a skeleton and build it all up as I go along with all the elements in place going through the real full game loop.
I have a question for you about TBEM and TBDI... in thinking about it the last couple of days... it seems that the two would go together really well. Here is what I was thinking:
All input would talk to general routines, that are actually then handled by TBEM as events. This way, the user then could via options ,set which input device they want to use and assign whatever keys they want, just in like in commercial games.
Have you done any tests for such configurations yet?
Michael Hartlef
13-06-2008, 12:22
I have a question for you about TBEM and TBDI... in thinking about it the last couple of days... it seems that the two would go together really well. Here is what I was thinking:
All input would talk to general routines, that are actually then handled by TBEM as events. This way, the user then could via options ,set which input device they want to use and assign whatever keys they want, just in like in commercial games.
Have you done any tests for such configurations yet?
Actually I didn't see much of use in this game for TBEM, so don't be sorry. And even if there was some usage, then it is still up to the coder(you) which tools you use.
No, I don't have such tests done yet. Sure it could be done, just like in a procedural way.
I will tinker with it Mike and see if I can figure it out.
zlatkoAB
15-06-2008, 10:18
What to say?
Super game-mr.Kent. :D
Thanks for trying it out ZlatkoAB and writing back. I hope it gives you some fun when you need a break!
Slight update to tank wars.
Worked on the Red and got more of the Nintendo Virtual Boy look from that cool game console from the mid 1990's.
Also tinkered with the Orange and made it a little brighter, so I think it looks a little better and more like the amber screens from years gone by.
Added 2 new colors, Cyan and Blue. Think of Blue as night mode, battling in the moon light :)
Download is in the first post:
http://community.thinbasic.com/index.php?topic=1798.msg13049#msg13049
Petr Schreiber
17-06-2008, 15:19
Thanks Kent,
looks very nice :)
Petr
Petr Schreiber
30-06-2008, 20:27
Hehe,
just found one very cool and recent book online :P
It shows Battlezone successor ( Tanks inspiration ) on "screen shot" (http://www.pointlessmuseum.com/museum/usbornecomputergames039.php).
Petr