Computer Science Canada GUNBOUND GAME - help me pahleez!!! |
Author: | Randolf Nitler [ 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) for x1 : 1 .. 1000 randint (upordown, 1, 2) yfill := y1 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 |
Author: | solinent [ 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. |
Author: | Randolf Nitler [ 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 |
Author: | HeavenAgain [ 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 |
Author: | syntax_error [ 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 |
Author: | Nick [ 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) |
Author: | HeavenAgain [ 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.... |
Author: | Randolf Nitler [ 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 ![]() |
Author: | HeavenAgain [ 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...... |
Author: | agnivohneb [ 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. |
Author: | Randolf Nitler [ 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? |
Author: | HeavenAgain [ 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. |
Author: | Randolf Nitler [ 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... ![]() |
Author: | Nick [ 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:
|
Author: | xdanielx98 [ 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 ![]() |
Author: | Randolf Nitler [ Mon Dec 24, 2007 2:25 pm ] |
Post subject: | Re: GUNBOUND GAME - help me pahleez!!! |
Great so that's fixed, but I still need the tanks to land onto my terrain, and they fail to do that. The problem is definately in my code. Should I use whatdotcolor function to check if the terrain color is green so i can stop moving my tank down the screen, or should I use whatcolorback? If you guys have time, could you guys explain to me how i should get my tanks to land on the terrain, and feel free to use the updated code xdanielx98 fixed up as an example ![]() |
Author: | Nick [ Mon Dec 24, 2007 2:33 pm ] |
Post subject: | RE:GUNBOUND GAME - help me pahleez!!! |
Randolf Nitler I found out why they aren't landing on the ground 1. check to see where everything is: ground ovals on top centered on the x and y location of player 2. check if oval is touching ground is oval center - oval y radius touching ground the problem is number two, you are checking if the oval's center equals brightgreen but instead you should be checking if the oval's bottom (the center - the y radius) is equal to brightgreen |
Author: | Randolf Nitler [ Thu Dec 27, 2007 3:16 pm ] | ||
Post subject: | Re: GUNBOUND GAME - help me pahleez!!! | ||
Alright well I tried momop's suggestion, the thing about checking if the oval's bottom (the center - the y radius) is equal to brightgreen. So basically what I did was this:
And... I still have the same problem, the tanks stay in mid air and don't move. Oh yeah and I used whatdotcolor to make life harder for myself ![]() |
Author: | Sean [ Thu Dec 27, 2007 4:11 pm ] | ||
Post subject: | Re: GUNBOUND GAME - help me pahleez!!! | ||
I've gotten the tanks to move for you, although now, I made a problem for you on purpose to see if you can fix it. After I did that, I added a cls to the end, which clears the screen. It then erases your grass. Fix that and your good.
I didn't actually mean to add the mistake of the grass disappearing! |
Author: | Saad [ Thu Dec 27, 2007 5:23 pm ] | ||
Post subject: | Re: GUNBOUND GAME - help me pahleez!!! | ||
Randolf Nitler @ Thu Dec 27, 2007 3:16 pm wrote: Alright well I tried momop's suggestion, the thing about checking if the oval's bottom (the center - the y radius) is equal to brightgreen. So basically what I did was this:
And... I still have the same problem, the tanks stay in mid air and don't move. Oh yeah and I used whatdotcolor to make life harder for myself ![]() The problem in your whatdotcolor collision detection, whatdotcolor takes retrieves a color at a specified x,y location, but you specify the y coordinate as the radius, which is 15, so its doing whatdotcolor(x-coordinate, 15) which means that you need to add the players y-coordinate . Also, you should check outside the radius of the oval and not inside, since y-coordinate + radius is still inside the circle. |
Author: | Randolf Nitler [ Fri Dec 28, 2007 8:58 pm ] | ||
Post subject: | Re: GUNBOUND GAME - help me pahleez!!! | ||
I fixed some stuff, and still have a teeny problem. See for yourself, the ovals do land on the ground, but after they do that they dissapear. And second, when one land on the ground before the other, they both dissapear even if the other didnt make it to the ground yet. How do i fix this.. Heres my code:
|
Author: | Randolf Nitler [ Mon Jan 07, 2008 11:33 am ] |
Post subject: | Re: GUNBOUND GAME - help me pahleez!!! |
Can som1 answer me please, i need this to continue! Thanks |