Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / SYNCING ARGH!

Author
Message
Nilrem
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 18th May 2003 16:08
Sorry, but I didn't know exactly what to put as the title.
Basically I took Sam's (Kangaroo2) advice, and started work on a Space Invaders game, but first did two crappy graphics and started coding...

it's hard to explain exactly what the problem is, because I don't know it, so if you would be so courteous as to compile the source below and download the two sprites. (I would be very grateful).

For the sprites.
http://www.grinders.withernsea.com/ar/red_dot1.bmp
and
http://www.grinders.withernsea.com/ar/spaceship1.bmp

Many, many, many thanks in advance.
-Nilrem
I hear and I forget. I see and I remember. I do and I understand.
Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 18th May 2003 16:49 Edited at: 18th May 2003 16:49
I wasnt so sure of what the problem was? But i think it was that the screen was blue instead of black on the background when waiting for input?

If so, i rewrote your collision sub routine for you. Heres the code (also in source window if you cant see the code button)



Let me explain it to you

First thing is i hide your two sprites as they really dont need to be there ^^ Then I setup a while loop. This loop will go on forever until a variable called decision has a value that is anything apart from 0. We will set its value to something when the user makes a choice.
Then I use the box command to draw a box over the screen - I find this to be more effective than cls().. i dont know why. But its a super fast command so it can be used to clear the screen just fine The last four parameters of the Box() command let you set a colour for each corner. Colour 0 is black. Usually you would want to set the box colours using the rgb() command to easilly set the colour without faffle, but as its easy to remember 0 as black we can just use that there (incidently, if you set different colours for different corners you will get a gradiant effect, i will leave you to play with that though).
Then I simply write some text to the screen. The text command is genrally much better than print for this task because you can set exactally where you want it to go. I used the Screen Width() and Screen Height() parameters to set the location of the text, they return the width and height of the screen respectivly/ Divide them by two and you get the middle of the screen - this way you ensure you draw to the same place no matter what the screen size is
Then instead of input (which hogs the program to itself) I use the Keystate() command to detect if the user pressed Y or N. Keystate() takes a scancode as its parameter. Every key on the keyboard has a scancode, but they are impossiable to remember If you want to know a keys scancode you can write a very short program which is basically this in a loop: Text 0, 0, Str$(Scancode()) - that writes the scancode of the key currently being pressed in the top left, very usful i find ^^ Keystate() returns 1 if the key belonging to the scancode you set is pressed.

(more than you need to know, but just incase you are confused about me writing "If Keystate(21)" rather than "If Keystate(21) = 1" its because an If statement is a boolean expression.. that is, if the condition is TRUE it excutes the code in its scope. As far as im aware, every value above 0 is counted as TRUE, so when the key is pressed and Keystate(29) equals 1 the code will execute without the need to explicity check that it = 1)

Scancode 21 = Y and Scancode 49 = N. If Y is pressed, we set the decision variable to 1. If N is pressed we set it to 2. (It seems common sense to set it to 0 if N is pressed, but our while loop will execute for as long as decision is equal to 0, so we set it to 2 instead). When decision = 1 or 2 the while loop stops and the If statement after is evaluated, if its 1 we reshow our sprites and restart the game, otherwise we simply end the program.

I hope that was usful to you ..i may of gone on a little bit too much and maybe talked about simple things you already know - but i wanted to be througher to avoid any confusion.

Feel free to ask anything else, even more so if interupted your problem completly wrong And good luck with your game ^_^

p4 2.4ghz, 256ddr ram, Geforce4 MX 440
Innovate, redefine, recreate whats in your mind. It isnt fate, you decide, only you can cross that line.
Nilrem
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 18th May 2003 16:55
Woah, hehe in-depth, thankyou Sephnroth, I'll give it a go and tell you how it.. goes.

I hear and I forget. I see and I remember. I do and I understand.
Nilrem
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 18th May 2003 16:58
Hey hey hey!! Sweet, it works, nice one, thanks a lot Sephnroth!!



I hear and I forget. I see and I remember. I do and I understand.

Login to post a reply

Server time is: 2024-11-24 14:52:56
Your offset time is: 2024-11-24 14:52:56