Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
lame game wont work
#11
keep in mind theres prolly a way better way of doing this...

regardless

personally id make a system where the shot has 1 of 4 attributes, being the direction shot. to actually move the shot,you could do somewhat of a counter system where there is a continuos counter that places objects.. for instance

Code:
do
Count = Count + 1
if Count mod 3000 = 0 then updateshot
if count > 60000 then count = 0 'keep it clean : )
'rest of code'
loop

then for the updateshot sub, you would check the case of the shot (array?) to see which direction it is going.

Code:
sub updateshot
select case shot(1)
case 1
'routine to move up
case 2
'routine to move down
case 3
'routine to move left
case 4
'routine to move right
end select
end sub

Hope that makes sense.. i couldve wrote actual code, but youll be able to implement the idea better if its your own code. peace out
[/code]
Reply
#12
i dont quite get it. my issue is the graphics, of course teh graphics go in hand with the code...
Reply
#13
Ok, I see what you mean.

What you want is a timer setup.

Here's the main loop that you want:

Code:
DO
'keyboard (and mouse, if you will use it) stuff. You want the player input polled as many times as possible.
1 i$ = INKEY$: IF I$ = "" THEN GOTO 1
SELECT CASE i$
CASE CHR$(0) + CHR$(72): dx% = 1
END SELECT

'actual game mechanics stuff! You want this to run every few milliseconds..
IF TIMER - t1# > 1 THEN game.step: t1# = TIMER

'display game stuff.. you want this to run as fast as possible.
update.screen
LOOP

In game.step, then, you would move the tank according to the last keyinput (like the dx% variable) and shoot the bullet.
If you want the bullet to move faster than the tank, you could just have a counter variable, as chaos mentioned.

So, for every unique time interval, you could do this:
Code:
SELECT CASE counter%
CASE counter% mod interval1% = 0 'shoot with tank
'blabllabla
CASE counter% mod interval2% = 0 'move tank
END SELECT

IF counter% > largest.interval% then counter% = 0
'largest.interval% is just the largest of interval1, interval2, etc.

So for the two cases, the respective events would happen when counter MOD that interval equals zero. Example:

interval = 2 (say, seconds)
counter = 1, counter mod 2 = 1. no event.
counter = 2, counter mod 2 = 0. event.
counter = 3, counter mod 2 = 1. no event.
counter = 4, counter mod 2 = 0. event.
etcetc.

See?
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#14
ok let's brake it down

Code:
'keyboard (and mouse, if you will use it) stuff. You want the player input polled as many times as possible.
that's the if inkey$ = up arrow then move sprite up?

Code:
1 i$ = INKEY$: IF I$ = "" THEN GOTO 1
if nothing is pressed go back to lable 1
Code:
SELECT CASE i$
CASE CHR$(0) + CHR$(72): dx% = 1
END SELECT
dont get that. what is the select case i$ for? and why is the key movement in there?

now graphicaly how do i make the shot? i want a red pixle to move accros the screen untill it hits some thing. to do tihs would i ahve to draw out each background tile with the pixle moving for each pixle then use a bunch of put to get it to move this sound s very slow. thanks for the help! Smile i leanr best from example if you dont mind.
Reply
#15
ok let's brake it down

Code:
'keyboard (and mouse, if you will use it) stuff. You want the player input polled as many times as possible.
that's the if inkey$ = up arrow then move sprite up?

Code:
1 i$ = INKEY$: IF I$ = "" THEN GOTO 1
if nothing is pressed go back to lable 1
Code:
SELECT CASE i$
CASE CHR$(0) + CHR$(72): dx% = 1
END SELECT
dont get that. what is the select case i$ for? and why is the key movement in there?

now graphicaly how do i make the shot? i want a red pixle to move accros the screen untill it hits some thing. to do tihs would i ahve to draw out each background tile with the pixle moving for each pixle then use a bunch of put to get it to move this sound s very slow. thanks for the help! Smile i leanr best from example if you dont mind.
Reply
#16
Quote: ok let's brake it down

Proofread your post! :|

Quote:
Code:
'keyboard (and mouse, if you will use it) stuff. You want the player input polled as many times as possible.

that's the if inkey$ = up arrow then move sprite up?

Just saying that the keyboard stuff starts there. That's all.

Quote:
Code:
1 i$ = INKEY$: IF I$ = "" THEN GOTO 1
if nothing is pressed go back to lable 1

That's label1, yes. You could do the same thing with another DO LOOP like all my... buddies... would do it.

Quote:
Code:
SELECT CASE i$
CASE CHR$(0) + CHR$(72): dx% = 1
END SELECT

dont get that. what is the select case i$ for? and why is the key movement in there?

i$ is the string that was taken from INKEY$. It's the key that was pressed. So that's why the key movement is there. Put all your key movement variable changes here.

Quote:now graphicaly how do i make the shot? i want a red pixle to move accros the screen untill it hits some thing. to do tihs would i ahve to draw out each background tile with the pixle moving for each pixle then use a bunch of put to get it to move this sound s very slow. thanks for the help! i leanr best from example if you dont mind.
That's graphically, pixel, accross, until, this, have, pixel, pixel, is, learned, don't. :|

Ok, graphically, you do this:
Code:
PSET (shot.x%(shot.num%), shot.y%(shot.num%)), 4
For every shot with lifespan > 0.. read on..

Every time a new shot is fired, you're going to have to increase shot.num% by 1 to make a new shot. (When it reaches the limit, just wait for one shot to free up and set it back to 0)

What do I mean by "free up"? Well, you're going to want to assign a lifetime for each shot, which then disappears after a certain number of frames. You're going to need a loop for that to process each active shot. (for each shot whose lifespan <> 0, subtract 1 from the lifespan.) In that same loop, you will want to increase the shot.x%() or shot.y%() by shot.dx() and shot.dy().

So you'll need the following arrays:

lifespan(1 TO shot.max%)
shot.x(...) ( or shotx%(), if you don't like periods.. )
shot.y(...)
shot.dx(...)
shot.dy(...)

So, every time a shot is fired, create a new shot, if shot.limit hasn't been reached yet:
shot.num = shot.num MOD shot.max
lifespan = lifespan max
shot.dx = current tank x direction
shot.dy = current tank y direction
add 1 to shot limit

and every time lifespan reaches 0,
subtract 1 from shot limit

(you're going to have the current tank x direction as positive/negative and the current tank y direction as 0, or the current tank y direction as positive/negative and the current tank x direction as 0)
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#17
ok makes more senece. sorry about the spelling i'm not the best speller. the short life i get. the shot travel for some time untill it goes away if it doesnt hit something. then you have a rate of fire. got any ideas on the graphics. this is some example i though up (lame)
Code:
SCREEN 13

FOR i = 1 TO 7
FOR y = 1 TO 5
FOR x = 1 TO 5
READ map
PSET (x, y), map
NEXT
NEXT
FOR time = 1 TO 100000: NEXT
NEXT


DATA 2,2,2,2,2
DATA 2,2,2,2,2
DATA 2,2,2,2,2
DATA 2,2,2,2,2
DATA 2,2,2,2,2

DATA 2,2,2,2,2
DATA 2,2,2,2,2
DATA 4,2,2,2,2
DATA 2,2,2,2,2
DATA 2,2,2,2,2

DATA 2,2,2,2,2
DATA 2,2,2,2,2
DATA 2,4,2,2,2
DATA 2,2,2,2,2
DATA 2,2,2,2,2

DATA 2,2,2,2,2
DATA 2,2,2,2,2
DATA 2,2,4,2,2
DATA 2,2,2,2,2
DATA 2,2,2,2,2

DATA 2,2,2,2,2
DATA 2,2,2,2,2
DATA 2,2,2,4,2
DATA 2,2,2,2,2
DATA 2,2,2,2,2

DATA 2,2,2,2,2
DATA 2,2,2,2,2
DATA 2,2,2,2,4
DATA 2,2,2,2,2
DATA 2,2,2,2,2

DATA 2,2,2,2,2
DATA 2,2,2,2,2
DATA 2,2,2,2,2
DATA 2,2,2,2,2
DATA 2,2,2,2,2
Reply
#18
Just use a red dot. . .! :|

You can keep the background in another video page and switch back to redraw the dot and tank in a different spot.

The graphics look very good for the scale of the map. Smile
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#19
Quote:You can keep the background in another video page and switch back to redraw the dot and tank in a different spot.
The graphics look very good for the scale of the map. Smile
the graphic i stole, once iget it working right i'll make my own. video page? a file/modoule containing al the DATA? swithci? ahhh! i'm glad i'll have thanks giving brake to think this over.
Reply
#20
oh...

Um, well, if you are going to use SCREEN 13, you need to write to page 0 and occasionally copy page 0 to page 1, the actual page that is seen. I think it goes something like this:

Code:
SCREEN 7, , 0, 1
FOR i% = 1 TO 100
CLS
PSET (50 + i%, 50), 4
PCOPY 0, 1
NEXT i%

Not sure how to do it in screen 13. (calls for reinforcements...)
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)