PDA

View Full Version : RobotDuel - game for 2 players



Petr Schreiber
08-06-2006, 15:38
Hi,

this is simple game featuring two robots.
You can play it alone against computer controlled enemy, but it is more fun for 2 players on one PC.

The goal of the game is to destroy your opponent and survive.
How to damage opponent? By damaging him using rockets !

Each player can control massive robot, which can move quite fast.
Player controls are simple, you will need only 5 keys to control the mechanical beast.

To make the gameplay more variable, version 1.5 introduced power-ups. They appear from time to time in the arena, falling from the sky.

At this time, there are 7 types of power-ups:

Double damage
Double speed
Shield
Regeneration
Slow opponent rockets
Crazy rockets
Cooler


Both you and AI can take the advantage of power-ups. But there is one problem - you never know which power up is in the box. Sometimes double damage effect for your rockets, sometimes tricky crazy rockets which are turning during the flight.

Try it on your own and let me know your impressions about difficuly levels, new powerups ...

Petr

P.S. Runs best on thinBASIC 1.3.0.1 and newer

UPDATED TO VERSION 1.7.3

Tweaked to run correctly with thinBASIC 1.6.0.10 and newer

Petr Schreiber
08-06-2006, 20:59
Added new version,

It improves visibility of the player numbers and does other important stuff.
The camera system now uses special beaviour when it tries to keep both robots always visible - this was bad in last version.

I changed the level appearance too, because I finally disliked it ;)
The new design is ... maybe strange for someone, but not as strange as not fitting skybox and desert layout in previous version.

Bye,
Petr

Petr Schreiber
11-06-2006, 23:33
Patched to version 1.4.1,

it fixes possible "Division by zero" bug, spotted by Eros.
Also there is smaller font, the 16 was too much :)

I'm now working on better AI for the singleplayer opponent.


Petr

ErosOlmi
11-06-2006, 23:51
Petr,

this game is fantastic, also considering it is only 700 lines of code.
Thanks a lot Petr.

To everyone: if you make some inetersting modification to sources like adding power-ups or whatever, consider to let us know in order to add new functionalities to official script. Your name will be listed into the script :)

Ciao
Eros

Petr Schreiber
12-06-2006, 23:09
New version uploaded !,

play tricks on your enemy using one of the 6 power ups!
Also few performance optimizations were performed for smoother playing.

Do you have idea about new powerUp ? Suggestion about difficulty levels ? Put it right here !


Petr

P.S. Eros thanks for action pictures!
P.P.S Forgot to say when something explodes nearby camera it will make it shake

Mark0
13-06-2006, 00:34
Very nice! :)

A couple of suggestion to consider, if I may:

- Rocket launchers overheating: so that simply firing keeping the fire button pressed all the time will lead to the lancher shutting down until it cool a bit (like in Mech Warrior, just to name one).

- The Rocket explosion could affect / alter the a robot position & heading (shaking it), depending on how near it explode and the relative position respect of the robots. So that if both robots are firing toward them, the first that will be hit will find itself in need to re-aim or move a little.

Again, excellent works!

P.S.
BTW, I added a new defs to my TrID (http://mark0.net/soft-trid-e.html) to identify the .M15 thinEdge models (http://mark0.net/soft-trid-deflist-m.html)! :)

Bye!

ErosOlmi
13-06-2006, 00:48
Marco,

thanks a lot for both (suggestions and .M15 extension consideration).
Petr will have a look at new features. I like a lot overheating. Maybe I will be able to win :)

Few images of the new version

Petr Schreiber
13-06-2006, 10:32
Hi,

Marco, thanks a lot for your suggestion! The idea is very good.
What do you think instead of shutting down to seriously damage the robot which tries to fire while its guns are too hot ?

The shaked aiming is next step to realism ( * not present in 1.5 :D )

Also thanks for indexing M15 format :)

Eros, thanks for the foto-report from action again! I was trying to catch some screens, but it is quite difficult to catch nice one :).

Thanks,
Petr

ErosOlmi
13-06-2006, 10:35
Have you seen my FPS :D

Petr Schreiber
13-06-2006, 10:38
Eros,

please don't try to play tricks on me. You must have joined 3 accelerators in megacrossfire mode :D

I never go below 29 FPS and higher than 37 :D But maybe it is more processor question, as there is no difference between 640x480@16 and 1280x1024@32.

Petr

ErosOlmi
13-06-2006, 10:51
I think in your last version you made some optimization in source code, isn't it?
Version without power-ups was slower, so the only way to have more options and more speed at the same time is more optimization.

So ... thanks.
;D

Petr Schreiber
13-06-2006, 11:07
Yes,

optimization is useful :). The last version runs faster by more than 5 FPS.
Luckily both aim-shake and overheat should not be such a big performance consumers.

Petr

Petr Schreiber
13-06-2006, 19:44
Hi,

version 1.5.5 is available now.

What's inside ? Implemented Marco's aim-shake and overheat ( if overheated you cannot shoot for a while ).
There is also new powerup "Cooler" which allows you to ignore overheating.
I'v added F12 key to quickly grab screenshots too.

The AI has different reaction time on different levels, so it should be easier to win over enemy bot.

Bye,
Petr

P.S. Eros, I'm now working on sidewalking. Quite complicated to introduce in 2 players game, because GetAsyncKeyState is not happy when too much normal keys are pressed. I'm searching solution now.

Petr Schreiber
14-06-2006, 14:55
Version 1.6 available

Why so early ? Now comes funny story from developing ;D

I tried to run RobotDuel 1.5.5 on PII 400 MHz and GeForce2 MX card.
I runned the script ... OH NO ! 3 frames per second at maximum !

I realized the computer has not installed latest 1.0.9.8. Uff, so that's the reason !
So I reinstalled it and runned ... again 3 FPS ! I was desperate, but then it hit me - the models are too complex for such a card - each robot has more than 5 000 polygons.

So version 1.6 is bundled with both high definition models and low definition ones ( one robot = 252 polygons ).

Just switching to lower detail models allows you to play the robots smoothly even on P II 400 MHz computer with GeForce 2 MX 400, maybe even slower. The dark side is that the low detail models really aren't too eye candy :D

Bye,
Petr

ErosOlmi
17-06-2006, 10:14
A little trick to pause hte game for a while.
To be added just after While IsWindow(hWnd) main loop.


if GetAsyncKeyState(%VK_P) then
sleep 100
PauseFlag = iif(PauseFlag = %TRUE, %FALSE, %TRUE)
end if
if PauseFlag = %true then
doevents
iterate while
end if

Petr Schreiber
17-06-2006, 10:22
Hi Eros,

thank you for the code, it works very good !
I will include it in next release if you don't mind.

I'm sorry I stopped updating RobotDuel for a while, but I'm just little bit busy at the moment.
As soon I'll have more time I will continue with updating.

Thanks,
Petr

ErosOlmi
17-06-2006, 10:27
Code published here is public, so do what you want.
Time is yours so, again, take care of it :D

We are working on 1.0.9.9
New features and no more restrictions like registration key or expire date.
Will be ready for next week.

Ciao
Eros

ErosOlmi
20-06-2006, 05:14
Petr,

what about a different type or armour other than rockets?
Also what about a new power-up that change the side where rockets starts? I mean rockets usually start from the front of the robot. With this power-up rockets can start from left side or right side or whatever.

Ciao
Eros

Petr Schreiber
20-06-2006, 09:43
Hi Eros,

very good ideas.

Armour
The armour will be changeable, I must redesign the head of the robot to have "weapon slots".
Here you could plug in weapons, which will probably fall from the sky like a powerups.

Firing side change
This will be quite connected with the armour - rockets will be probably situated on the sides ( idealy shooting from left,right,left,right ... ), machinegun or something like it on the place where rockets are now and other ... we will see :)

I'd like to take advantage of "math" module from 1.0.9.9, so I will arrange the code too and make a general source cleanup.

I hope to release new version this weekend


Thanks,
Petr

ErosOlmi
20-06-2006, 09:53
And if you need any new native math function, just let me know and I will add immediately.
Ciao
Eros

Petr Schreiber
25-06-2006, 14:09
Hi,

thanks for the offer Eros, but it seems I don't need any special function now.

I'm afraid I can't release new version this weekend as I wanted, because I got few mad ideas which I would like to introduce and they are little bit time consuming :).

But they could make the fights more intense.

At this time I have included:
+ Your pause code
+ Left-Right rocket launch
+ Few optimizations


Petr

Petr Schreiber
10-07-2006, 18:28
Problems !

I'v tested RobotDuel script on computer with 2GHz + Pentium 4 processor, 1 GB RAM and ATi Radeon X600 card. Sadly I can't continue the tests now.

... and I was shocked! The script behaved like a crazy one. After few steps with robot the robot returned back to its original location! Even if I fired rockets they "jumped" back after ~1 second. Also the overheat bars indicated the robots are continuously firing but no rockets/explosions were visible!

Do you have similar terrible experience ? Any ideas ? Could it be done by some spyware/trojan/... running on background ?


Thanks,
Petr

P.S. The game was running about 97 FPS

RobertoBianchi
10-07-2006, 23:15
Hi Petr,

spyware/trojan? I'm not sure if they can drive a robot.
Did you changed your module recently? Or mixed some TB module with different version?
May be you are using TB for Win Me in Windows XP box?
Other scripts running in regular way?

Please keep us involved.

Ciao,
Roberto

ErosOlmi
10-07-2006, 23:37
No problems here Petr.

Intel Centrino Duo, WinXP, ATI Mobility Radeon X1600,

Petr Schreiber
11-07-2006, 10:07
Hi Roberto and Eros,

thanks both for your replies.
Regarding spyware/trojan/virus suspicion ...

At first it seemed to me some hidden program is pressing the keys and that makes GetAsyncKeyState confused. But it would not explain why the ( periodical! ) robot and rockets position reset occured. It seemed like a calling of InitGame function every 1 second or so. But that would not make rockets jumping back. Or it could be some strange return value ( negative ) from help_CalcFrameRate proc.

I used latest thinBASIC 1.0.10.1 and both official TBGL module 0.1.6 and pretty secret 0.1.7 :) too.

I'm very confused, because it worked without problems on computers from PII 400MHz, Win 98 to Eros NASA One :)

This computer was beetween this configurations, FPS shown were not extreme ( just very high )

I'll try to get on that computer ASAP, or at least navigate test runs of the owner using email.

The other TBGL scripts ran well, EXCEPT TBGL_Fun_SpaceShooterGame.tBasic, which showed me static screen with very weird output. I was also unable to get to the graphic drivers ( ATi Catalyst ) setup on that box. Very strange behaviour.


Thanks,
Petr

RobertoBianchi
11-07-2006, 13:06
Hi Petr,

I can start the robot but after fews seconds it reset back.

Game is running on Intel Pentium 4 2.8GHz, ATI RADEON 9200, Windows XP sp2 @77FPS.

Ciao,
Roberto

ErosOlmi
11-07-2006, 14:48
Petr,

I think the problem is related to help_CalcFramerate script function.
If it returns low values (1 to 5 or so) than some strange camera shake plus reset occurs.

It also depends on FPS capacity. On fast video card/computer like mine, script runs at about 140FPS and this problem does not occur or at least it is not so evident.

Ciao
Eros

Petr Schreiber
11-07-2006, 17:09
Thanks for the information !,

now comes the paradox :(. My brothers PC ( PII400 MHz, 256MB RAM and nVidia Geforce2 MX 400 64 MB) runs the script at 20 FPS. This is not super, but okay.

Eros runs it at 140 FPS and it runs OK.



If it returns low values (1 to 5 or so) than some strange camera shake plus reset occurs.


Yes, then the robots make bigger steps to compensate the speed problems.
But the probematic box runned it at 97 FPS, Roberto's PC runs it at very high 77 FPS too.

This is not "extremely low" framerate and it is between two tested framerates :(

I run it at 50 FPS and no problem occur.

It seems 70 - 100 FPS is dead zone :) But why ? If the queryperformancecounter and queryperformancefrequency would not work, it would mean it would not report logical framerate, but it does.

The only thing which occurs to me is to declare LastTime, ThisTime as QUADs, because Microsoft Win32API help says



BOOL QueryPerformanceCounter(
LARGE_INTEGER *lpPerformanceCount // address of current counter value
);


I presume thinBASIC equivalents are wrappers of this API.
So Roberto, if you can, please try to replace the function mentioned by Eros with this corrected:



'------------------------------------------------------------------
' FPS CONTROL - to get the speed and synchronize animations
'------------------------------------------------------------------
FUNCTION help_CalcFramerate() AS SINGLE

GLOBAL LastTime AS quad
LOCAL ThisTime AS quad
LOCAL FPS AS quad
local Divisor as quad

ThisTime = queryperformancecounter
Divisor = ThisTime-LastTime
if Divisor = 0 then Divisor = queryperformancefrequency
FPS = queryperformancefrequency/Divisor
IF FPS = 0 THEN FPS = 1
LastTime = ThisTime

FUNCTION = FPS

END FUNCTION



Thanks,
Petr

RobertoBianchi
11-07-2006, 18:06
Ok, I tryed and it working well!

Ciao
Roberto

Petr Schreiber
11-07-2006, 18:20
Ok, I tryed and it working well!


Yahoo :) Thanks for this message ! I will update the download this night to protect rest of the World from "Terrible mystery of jumping robots" :D


Thanks to you and Eros for suggestions leading to solution of the problem,
Petr


P.S. Eros, when you'll have time, would it be possible to change "Returns: Number" to "Returns: QUAD" in help file for QueryPerformanceCounter and QueryPerformanceFrequency ?

[EDIT] Version 1.6.4 is available for download

RobertoBianchi
12-07-2006, 08:36
Hi Petr,

I tryed the 1.6.4 version and I got this error:

Ciao,
Roberto

RobertoBianchi
12-07-2006, 11:22
Hi Petr,

I'm sorry, please discard my previous post because I was out-dated, now working fine @103FPS. :-[

Regards,
Roberto

ErosOlmi
12-07-2006, 12:17
P.S. Eros, when you'll have time, would it be possible to change "Returns: Number" to "Returns: QUAD" in help file for QueryPerformanceCounter and QueryPerformanceFrequency ?

Petr,

almost all internal thinCore calculations are made using EXT numeric data type.
When thinBasic encounter a generic NUMBER like in DIM MyVar as NUMBER in reality it creates an EXT data type. All functions declared to return a generic NUMBER in reality they return an EXT number. If you assign the return value of QueryPerformanceCounter or QueryPerformanceFrequency to a QUAD number, thinBasic takes care of relevant numeric conversions.

Ciao
Eros

Petr Schreiber
12-07-2006, 20:58
Hi,

Roberto, how could you live without latest fresh versions of tB with Math module? ;D
Anyway, you jumped from 77 to 104 FPS ? I did not think the correction of AI "IF" statement and Math module optimization will have such a result :)

Eros, thanks for the information. I just wanted to express if someone does not use general "AS NUMBER" declaration and tries to use "exact" LONGs, SINGLEs ... instead of it to get the maxximal performance, he could be surprised like me. There could be also little problem for DOS extremists with their love for INTEGERs :) But now I get it and no other statement does any problems to me. So ... all is ok :)


Thanks,
Petr

RobertoBianchi
12-07-2006, 22:10
Hi Petr,

yes I discovered now why my life was becoming harder ;D
As you can see Eros is careful and thrifty to distribute upgrade not only with the online guys ::)

Also I'm remained been impressed to have earned 26 FPS! :o
However tomorrow I'll check better then I'll let you know. ;)

Ciao,
Roberto

ErosOlmi
13-07-2006, 02:01
Regarding FPS change, it all depends by the exact moment in which you get the screen picture. FPS can be very unstable in a short time period (let say few milliseconds). If you take the picture in a precise moment, just after few milliseconds FPS can be very different.

On my box I can go from 50 FPS to 150 FPS in just 1 second. Remember we are executing scripts and not pure machine code, so parsing and script interpretation is the hardest and most CPU consuming part.

I know thinBasic is very fast and sometime we have the impression to execute an EXE program but never forget we are executing scripts ;D

Ciao
Eros

RobertoBianchi
13-07-2006, 12:43
Hi,

I changed the ROBOTDUEL script for calculate the FPS average and letf the game running more time for 2+ minutes, so I can confirm the 100 FPS.

Ciao,
Roberto

Petr Schreiber
13-07-2006, 13:26
Hi,

thanks for the replies.
Eros, you're right, FPS can vary. On my box the FPS deviation is not as brutal as on yours, its about 3 FPS up and down ( but I never achieve 150 :D ).

Roberto, thanks for information on FPS. I'm thinking about "Run Benchmark" mode for testing purposes.

Thanks,
Petr

RobertoBianchi
13-07-2006, 14:23
Hi Petr,

I made a simple but efficient average calculation, you can see it in the attached code.

Ciao,
Roberto

Petr Schreiber
13-07-2006, 21:01
Hi Roberto,

nice code. Can I integrate it to next release of RobotDuel ?

Thanks,
Petr

RobertoBianchi
14-07-2006, 09:19
Oh yes of course, I will be a lot honored from that! :)

Ciao,
Roberto

ErosOlmi
04-08-2006, 16:06
Petr,

what about an option to move camera inside the head of the robot?
It will be like having first person game.

A key to switch from first person view to automatic moving camera and the other way round.

Ciao
Eros

Petr Schreiber
04-08-2006, 22:23
Hi Eros,

I will implement it.
Maybe some kind of HUD ( Head-Up-Display ) will be introduced for this view.

I will release next version of RobotDuel when TBGL 0.1.7 will be finished and out, to take advantage of its new capatibilities too.


Thanks a lot,
Petr

ErosOlmi
04-08-2006, 22:41
Ok, fine.

We will be back 100% on the project at the end of August.
In the meantime we are finishing help and bit of work on COM. Nothing more in next 2 weeks. We will release other 2/3 1.0.10.2 intermediate release.

Ciao
Eros

Petr Schreiber
05-09-2006, 11:19
Hi all,

I'v updated the RobotDuel to version 0.1.7.

At this time it has cosmetic changes only, functionality is the same.

So what's new ? The model loading is now handled by TBGL module, so it is quite fast, function to calculate framerate is also gone and replaced with TBGL function.

This version no longer needs the include files as before.

I'm prepairing more radical changes, but it will take some time. The first person view is little bit tricky in mode for 2 human players, I will probably arange it with two viewports in future releases.

Eros found a problem in one version of this release, so I discovered nasty bug in my TBGL module, fix will be in next release of tB

Bye,
Petr

Petr Schreiber
08-09-2006, 17:07
Hi,

new version is out! Eros inspired me by sending me sample program for PB, so I added sound to thinBASIC RobotDuel too. It is MIDI powered - so no need for extra sound files to download.

Off course, if you don't want to hear the sound, you can disable it in options ( or turn off speakers :D )


Bye,
Petr

cocoflop
12-05-2007, 22:05
Great Work! ;D

I discovered a bug, when I enable "Draw Chunk Effects" checkbox. The game freezes on initialation and show the following error. Otherwise it works perfect.

error code 21
description Expected comma ',' but found something else.
line number 652
line code TBGL_ROTATE ((I*10+GETTICKCOUNT))*CHUNKSIZE(I)*100,1,1,1

Petr Schreiber
12-05-2007, 22:09
Hi,

thanks, RobotDuel was fun to code, and I got lot of important suggestions from friends on forum.

Regarding problem - thank you for reporting it :)
This problem was not always in the game, but latest thinBASIC changes a bit the way it was meant to be parsed, so you need to enclose all parameters with parenthesis.

I will correct this issue and repost new version ASAP


Thanks !,
Petr

P.S. If you want to get it working now and enjoy chunk effects, please just change the problematic line to:


TBGL_ROTATE ( ((I*10+GETTICKCOUNT))*CHUNKSIZE(I)*100,1,1,1 )

Petr Schreiber
05-07-2008, 23:01
Updated to 1.7.3 - there were some compatibility problems with MOD function.
Too bad, 153 downloads looked cool :)


Petr

ErosOlmi
05-07-2008, 23:10
Thanks Petr.

I will update TBGL Bonus Pack present in thinBasic download area (http://www.thinbasic.com/index.php?option=com_docman&task=cat_view&gid=23&Itemid=66) very soon.

Ciao
Eros

kryton9
05-07-2008, 23:40
I will wait to grab it from the bonus pack. This way I know everything will be the latest. Thanks guys!

E.K.Virtanen
30-05-2011, 07:06
Nice one. You are da man Petr :)

Petr Schreiber
30-05-2011, 14:15
Thanks,

this game was collaborative effort. When I look at the code, I see how long path ThinBASIC went since then. In few days it will be 5 years since release!

I would like to modernise the code to showcase new approaches better, but I guess fresh new game would be better idea ;)


Petr

ErosOlmi
30-05-2011, 20:19
Incredible to see that this old great example is still running fine even if thinBasic and all used modules changed so much improving and adding features along the years
;)