Page 1 of 2

Another early tanks game

Posted: Wed May 20, 2009 9:44 pm
by paclito
Hi all

I'm trying to make a clone of the wii game 'tanks' where it's from one to four player and the goal is to destruct the enemy tanks.... so...... i've get some of the programs in the forum and i've done something....... not the game :megagrin:

First
The map is made with mappy and exported with the script tolua.lua .... for the script to work, only edit the file mappy.ini and edit one of the custom lines to appear like this:

lua16=tolua.lua

then, copy the script tolua.lua to the luascr directory and reopen the mappy program

I've make the map that is in the love file.

Second
I've get some examples from here nimball, zgeigcopters and anothers and get ideas from them, the result is this frankenstein

for the moment we only can to move the tank (arrow keys) and shot with space bar....... but shot five shots every time..... i've no idea WHY aaaaaaaarg :shock:

someone can help this programmer?

sorry for my english and thank you all, without the examples here, this is not posible to make this little example

Update1: I've forget that the code to 'make' the Walls (up down right left) is'nt 'automatic' jejejee

Update2: I've see when the five shots bump 5 or 6 times.... they cross the walls ;) and there is not more 'boing' 'boing'

Re: Another early tanks game

Posted: Wed May 20, 2009 9:59 pm
by Robin
Hi,

I tried your demo. Looks promising, although very unfinished ;). The bullets still behave very odd. Also: they seem to keep bouncing around. You are aware that in the Wii game, the "bullets" (shells, actually) explode on the wall after having bounced once?

Also, your English is not that hard to read. Your code would benefit from more consistent indentation, but that's a separate matter.

Re: Another early tanks game

Posted: Thu May 21, 2009 6:42 am
by bartbes
I think I have an idea of why you fire five bullets, you're probably doing love.keyboard.isDown, right?
But in the time it takes for you to 'tap' your keyboard the code has already executed that five times.
So, if you move that code into keypressed or keyreleased (keypressed is recommended for responsiveness) you only fire once every time you press the button.


AFTER SOME RESEARCH IN YOUR CODE:
I didn't exactly look up why the limit is five, but I guess the rest of my assumptions are correct, I see you just stop firing once the key is released, but start with isDown. (or not with keypressed, so I assume that is isDown)

Re: Another early tanks game

Posted: Thu May 21, 2009 7:45 pm
by CR4SH3D
looking good so far :)

bartbes is probably right about why you cant shoot properly, would be great to see more stuff, good luck

Re: Another early tanks game

Posted: Sun May 24, 2009 12:02 am
by paclito
ok, i'm trying this but still having problems with the shots arggggggggggggggggggggggg.
Now i'v a only shot when key pressed ....... but shots are crazy...... always same angle same direction ....... same all I,m the last 3 days with this brainstorm..... for now my tank only likes to shot 45º from up to down...... only work the 'auto fire'
if space pressed a strange error appears on screen.

UPDATE1:
the super explossion over the tank is my try for make a explosion at the end of canon when a shot occurs (keypressed) ....... still not working you can see :)

Good luck to all coders!!!

Re: Another early tanks game

Posted: Sun May 24, 2009 6:24 am
by bartbes
Well, I didn't look at the angle problem, but I do know why your shot errors, in main.lua you call player:shot(), which doesn't have a turret initialized (so tank_turret == nil, as the error says), it should be player1:shot().

Re: Another early tanks game

Posted: Sun May 24, 2009 8:52 am
by paclito
aaaaaaaaaaaaaaaaaaaaaaaaaarg!!!

I'm seeing this error for 3 days and haven't see aaaaaaaaaaaaaaaaaaaaaaaaaarg!!!
i dream with tanks ... with errors aaaaaaaaaaaaaaarg!!!


thank you!

Re: Another early tanks game

Posted: Sun May 24, 2009 11:58 am
by CR4SH3D
call a function with a time to spanw the explosion only once when space is pressed
as for the bullets im afraid i think theres some complex stuff you have to do with the angle of the turret and x,y coordinates, im not sure what but i vaguely remember something similar from maths

Re: Another early tanks game

Posted: Sun May 24, 2009 11:59 am
by bartbes
I haven't checked your code for this, but have you converted between degrees and radians?

Re: Another early tanks game

Posted: Sun May 24, 2009 12:45 pm
by CR4SH3D
i dont think he would have, is there a tutorial on doing that anywhere? (not neccesarily a love specific one)