Posted: Mon Dec 17, 2007 6:51 pm Post subject: GUNBOUND GAME - help me pahleez!!!
Im making a game that resembles gunbound or tanks. I have a map generator and two tanks that will be generated randomly on the screen. Problem is that i cant get them to land on my terrain, and when they fall from the sky while generating, i see a large blur, and in the end i can't locate my tank. Can you guys help me get my tank on the terrain without the large blur? Thanks, here's the code:
%TERRAIN GENERATOR
var upordown, y1, yfill : int
randint (y1, 100, 150)
loop
drawdot (x1, yfill, brightgreen)
yfill := yfill - 1
exit when yfill = 0
end loop
if upordown = 1 then
y1 := y1 + 3
else
y1 := y1 - 3
end if
end for
% variables for generating locations
var player1locationY, player1locationX, player2locationY, player2locationX : int
% Player one location generator
randint (player1locationX, 10, 450)
player1locationY := 400
% Player two location generator
randint (player2locationX, 460, 690)
player2locationY := 400
loop
if whatdotcolor (player1locationX, player1locationY) not= brightgreen then
player1locationY := player1locationY - 2
end if
exit when whatdotcolor (player1locationX, player1locationY) = brightgreen
drawfilloval (player1locationX, player1locationY, 15, 15, brightred)
if whatdotcolor (player2locationX, player2locationY) not= brightgreen then
player2locationY := player2locationY - 2
end if
exit when whatdotcolor (player2locationX, player2locationY) = brightgreen
drawfilloval (player2locationX, player2locationY, 15, 15, brightblue)
end loop
Sponsor Sponsor
solinent
Posted: Mon Dec 17, 2007 6:56 pm Post subject: Re: GUNBOUND GAME - help me pahleez!!!
I haven't read your code entirely: however, it seems like you aren't clearing the screen.
Randolf Nitler
Posted: Mon Dec 17, 2007 6:58 pm Post subject: Re: GUNBOUND GAME - help me pahleez!!!
yah i know, ive tride using cls, but then my terrain disapears and i do sere my tanks but they keep flashing in the middle of a blank screen
HeavenAgain
Posted: Mon Dec 17, 2007 7:27 pm Post subject: RE:GUNBOUND GAME - help me pahleez!!!
whenever you clean your screen you have to redraw the things, again, and having View.Set("offscreen") at the top of the code and View.Update after every cls should solve the flashing problem
syntax_error
Posted: Mon Dec 17, 2007 11:35 pm Post subject: Re: GUNBOUND GAME - help me pahleez!!!
err im not sure but isn't it
[code="Turing"]
View.Set ("offscreenonly")
no just View.Set("offscreen")
[/code]
btw try using code tags makes everyones life easy and all it takes is a click
Nick
Posted: Mon Dec 17, 2007 11:47 pm Post subject: Re: RE:GUNBOUND GAME - help me pahleez!!!
HeavenAgain @ Mon Dec 17, 2007 7:27 pm wrote:
...View.Update after every cls should solve the flashing problem
close HeavenAgain but its should be a cls after every View.Update (otherwise you show your newly cleared screen)
HeavenAgain
Posted: Tue Dec 18, 2007 12:10 am Post subject: RE:GUNBOUND GAME - help me pahleez!!!
well... you get the idea :p
and i was wrong about offscreenonly, oh dear....
Randolf Nitler
Posted: Tue Dec 18, 2007 12:02 pm Post subject: Re: GUNBOUND GAME - help me pahleez!!!
using the code i posted above, can you tell me where to put the view updates and the cls's cuz im too noob to figure it out for myself =D Thanks again
Sponsor Sponsor
HeavenAgain
Posted: Tue Dec 18, 2007 12:17 pm Post subject: RE:GUNBOUND GAME - help me pahleez!!!
too "noob" or too lazy? Heres what you have to do:
put View.Set("offscreenonly") at the very top of your code
and View.Update before every cls
and the problem with your program is, when you clear screen, your background disappears, to fix that you have to redraw the background again
*there is a way not to use cls, is something like redraw the box region or something... it might be for picture files only though, im not sure*
and you are using whatdotcolour to check if the tank landed or not, which can be a bit inaccurate......
agnivohneb
Posted: Tue Dec 18, 2007 1:20 pm Post subject: RE:GUNBOUND GAME - help me pahleez!!!
to have your terain redraw set it up in a procedure that will draw it whenever you want and also have a external array of 1 to 1000 to store your values of y1.
In my opinion you should use Draw.Line instead of drawdot. this can get rid of that loop and improve that speed.
Is this for a school project or are you just board? If it is for school you would want to tidy it up a little and you don't need the yfill var. it would make more sense to reuse the y1 var. I seen a lot of student get low marks for this on very good programs.
also when generating the terrain you would want to set a min and max for it so it doesn't go were you can't see it. You can also get errors for something like that.
It may seem a lot at once but give it a try.
Randolf Nitler
Posted: Tue Dec 18, 2007 2:52 pm Post subject: Re: GUNBOUND GAME - help me pahleez!!!
Quote:
and you are using whatdotcolour to check if the tank landed or not, which can be a bit inaccurate......
so what would i use to make it accurate?
HeavenAgain
Posted: Tue Dec 18, 2007 3:39 pm Post subject: RE:GUNBOUND GAME - help me pahleez!!!
finding the coordinate of the ground surface, and see if your tank's bottom passed the surface? some simple math is involved.
Randolf Nitler
Posted: Tue Dec 18, 2007 6:48 pm Post subject: Re: GUNBOUND GAME - help me pahleez!!!
Alright ill get try to examine some of your suggestions more closely, but back to my View.Update and cls inquiary, I dunno where exactly i should put the View.Update's and the cls's in my program. Is it in my loops, before my loops or after my loops, because order is important. Could you just clear this up for me, and once this is fixed, it looks like im pretty good, for now...
Nick
Posted: Wed Dec 19, 2007 6:34 am Post subject: RE:GUNBOUND GAME - help me pahleez!!!
first you draw everything there is to draw then you show it with View.Update then you clear the screen with cls
example:
code:
View.Set("offscreenonly")%same as setscreen
for i:1..maxx
drawfilloval(i,10,5,5,black)
View.Update
cls
delay(50)
end for
xdanielx98
Posted: Thu Dec 20, 2007 12:33 pm Post subject: Re: GUNBOUND GAME - help me pahleez!!!
as far as things go with your objects not being able to land on the ground I havent had a chance to take a look at that, but I have got it so that the objects drop at a more suitable rate and so that they are exactly that an object and not just a continuous line that is going down the page... I did it with really basic code just drawing the shape, updating the screen then after the update erase it and redraw it with the new coords, I will take a look at the other code to try and have it so that you dont keep on going