LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

Making a Shoot 'Em Up Game, but still with some doubts.

Root / Programming Questions / [.]

the_squat1115Created:
Hi, I'm recently working on a Shoot 'Em Up game called Galaxy Blaster (Probably I could change the name), because I got some knowledge by digging on that GAME4SHOOTER game, because I wanted to make a modification of it. But ended up with this. Here is what I've learned:
LAY=0 'Layer of the BG to scroll, think like LAY=[NUMBER].
BG0Y=-3 'Speed of the BG, depending on the style of Shoot 'Em Up you want, vertical or horizontal.
BGOFS [LAY],[code, code, code]
[code, code, code]
But everything left are: ●Maps made with
DATA
●Enemy generating with
DATA
●Collision detection ●Boss engine and mechanisms Tell me if something had passed up from me.

Interesting. I probably could answer a few of your questions, but I don't want to lecture. I guess for maps with DATA, you have a BG table array.
DIM BGTABLE%[10]'This can have any number, 10 is used in this example.
You also have a map data array (string array). Like so:
DIM MAPL0$[15]
It has an element for each 16x16 horizontal strip, here is a diagram to demonstrate what I mean:
1:■■■■■■■■■■■■■■■■■■■■■■■■■
2:■■■■■■■■■■■■■■■■■■■■■■■■■
'all the way to 15
We will come back to this array when reading the map data. You can set these values to what ever background tile number you want them to be; 0, 1, 5, 57, 294, 1016, or any other tile you want to use. Then with DATA you write your maps with whatever you represent them as. I would recomend doing this with character codes that increase by 1 each time. It could be
1234567890
or
ABCDEFGHIJ
or anything that works like that. One way you can make sure you are going in the right order is with CHR$(). Like
?CHR$(57)
'prints character
?CHF$(58)
'prints next character
So you have your map data. It could be something like this:
DATA "0000000000000000000000000"
DATA "1000008000000000000000000"
DATA "3100076700000000000040000"
DATA "2100008000005000000000000"
DATA "1000000000000000000000000"
but it could also be anything else. Before you have your map data you can have BG table data, to set your BG table. Like this:
'BG TABLE DATA
DATA 375'BGTABLE[0]
DATA 376'BGTABLE[1]
DATA 465'BGTABLE[2]
DATA '...
'MAP DATA
DATA "0000000000000000000000000"
DATA '...
So reading all of this is kinda interesting. Before the data, you might want to put a lable, so you can easily do multiple maps:
@MAP0001
DATA '...
So anyway, in reading this, you put RESTORE "lable name":
RESTORE "@MAP0001"
It doesn't need to be a string, and people don't usually make it a string; with strings it's easier to comprehend receiving data from another slot:
RESTORE "1:@MAP0001"
Then you would read your bg table with something like this:
FOR I=0 TO LEN(BGTABLE)-1
 READ BGTABLE[I]
NEXT
And then you would read your map data. It would be something like this:
FOR I=0 TO LEN(MAPL0$)-1
 READ MAPL0$[I]
NEXT
That's fairly simple. Displaying the map is a bit more complex. To display it, you could do a lot of things. But this is the way I learned how to display the map, so use it and study it as you wish.
FOR I=0 TO LEN(MAPL0$)-1
 FOR J=0 TO 24
  IF ASC(MID$(MAPL0$,J,1))>=[the lowest character code] && ASC(MID$(MAPL0$,J,1))<=[the highest character code] THEN BGPUT I,J,BGTABLE[ASC(MID$(MAPL0$,J,1))-[lowest character code]]
 NEXT
NEXT
I got kinda messy in displaying that code, but I'm sure it still at least slightly illistrates what I'm trying to say. Lots of string functions, lots of frustration :) I love string functions

We will come back to this array when reading the map data. You can set these values to what ever background tile number you want them to be; 0, 1, 5, 57, 294, 1016, or any other tile you want to use. Then with DATA you write your maps with whatever you represent them as. I would recomend doing this with character codes that increase by 1 each time. It could be
1234567890
or
ABCDEFGHIJ
Or something that works like that. One way you can make sure you are going in the right order is with CHR$(). Like
CHR$(57) 'prints the character
CHR$(58) 'prints next character
So you have your map data. Something like this:
DATA "000000000000000000000000"
[...]
I could try this, if I can. Posting results when I'm ready!
FOR I=0 TO LEN(BGTABLE)-1
 READ BGTABLE[I]
NEXT
This just comes with me with a type mismatch. Help please? EDIT: nvm, it just fixes when I put the string ($) symbol. EDIT 2: It doesn't generates the map for some reason, just comes with an error...

This just comes with me with a type mismatch. Help please? EDIT: nvm, it just fixes when I put the string ($) symbol.
NO don't make it a string. You need to create the variable as an array:
DIM BGTABLE[10]'Any number can go inside, 10 is a good one though
not a string.

This just comes with me with a type mismatch. Help please? EDIT: nvm, it just fixes when I put the string ($) symbol.
NO don't make it a string. You need to create the variable as an array:
DIM BGTABLE[10]'Any number can go inside, 10 is a good one though
not a string.
I just get a type mismatch on line 46 or something... Where it's reading the BG Table.

What exact code is there? Did you put all the BG tiles BEFORE your map data? The data should be like
@MAP0001
DATA 18'BGTABLE 0
DATA 28'BGTABLE 1
DATA 47'BGTABLE 2
DATA 384'BGTABLE 3
DATA 375'BGTABLE 4
DATA 294'BGTABLE 5
DATA 373'BGTABLE 6
DATA 928'BGTABLE 7
DATA 264'BGTABLE 8
DATA 546'BGTABLE 9
DATA"0000000000000000000000000
DATA"0000000000000000000000000
DATA"0000000000000000000000000
DATA"0000000000000000000000000
DATA"0000000000000000000000000

What exact code is there? Did you put all the BG tiles BEFORE your map data? The data should be like
@MAP0001
DATA 18'BGTABLE 0
DATA 28'BGTABLE 1
DATA 47'BGTABLE 2
DATA 384'BGTABLE 3
DATA 375'BGTABLE 4
DATA 294'BGTABLE 5
DATA 373'BGTABLE 6
DATA 928'BGTABLE 7
DATA 264'BGTABLE 8
DATA 546'BGTABLE 9
DATA"0000000000000000000000000
DATA"0000000000000000000000000
DATA"0000000000000000000000000
DATA"0000000000000000000000000
DATA"0000000000000000000000000
The DATA ones are tiles? Testing it...

[...] I could try this, if I can. Posting results when I'm ready!
FOR I=0 TO LEN(BGTABLE)-1
 READ BGTABLE[I]
NEXT
This just comes with me with a type mismatch. Help please? [...]
This Code generate the Error because BGTABLE after LEN is not defind. You only have defind BGTABLE[Map%] So try
FOR I=0 TO LEN(BGTABLE[Map%])-1
 READ BGTABLE[I]
NEXT
Dont forget to set "Map%" as a Number before using. (You can also use "Map$" - its youre choise.)
what no BGTABLE is an array containing the data for which tile is represented by what. I believe that the error was generated because it read map data (strings) into the bg table (numbers) because the bg tiles weren't set before the map data. Therefore, it skipped straight to the map data and didn't like the strings.

@random_god If you create a array like
 BGTABLE[10] 
you can use it only if you type it correctly. Otherwise a error will show (with OPTION STRICT) or it will not work. Of course you can use a variable and a array with the same name, but this makes things harder to debug. In this case: The code try to read this Data-lines: "0" , "-1". Data-line "-1" is not possible = Typ mismatched.
I don't get what you are saying. If the problem is if you type it wrong, that's the case with everything. I will make a demo program to show what I mean. KEY: REMOVINATED sorry just look at it

@random_god If you create a array like
 BGTABLE[10] 
you can use it only if you type it correctly. Otherwise a error will show (with OPTION STRICT) or it will not work. Of course you can use a variable and a array with the same name, but this makes things harder to debug. In this case: The code try to read this Data-lines: "0" , "-1". Data-line "-1" is not possible = Typ mismatched.
I don't get what you are saying. If the problem is if you type it wrong, that's the case with everything. I will make a demo program to show what I mean. 7K3KQ3NX just look at it
Thanks! I just copied the code to mine and it works! Thanks, random_god!

@random_god If you create a array like
 BGTABLE[10] 
you can use it only if you type it correctly. Otherwise a error will show (with OPTION STRICT) or it will not work. Of course you can use a variable and a array with the same name, but this makes things harder to debug. In this case: The code try to read this Data-lines: "0" , "-1". Data-line "-1" is not possible = Typ mismatched.
I don't get what you are saying. If the problem is if you type it wrong, that's the case with everything. I will make a demo program to show what I mean. 7K3KQ3NX just look at it
Thanks! I just copied the code to mine and it works! Thanks, random_god!
Make sure to study the code too, so that you know how it works.

@random_god If you create a array like
 BGTABLE[10] 
you can use it only if you type it correctly. Otherwise a error will show (with OPTION STRICT) or it will not work. Of course you can use a variable and a array with the same name, but this makes things harder to debug. In this case: The code try to read this Data-lines: "0" , "-1". Data-line "-1" is not possible = Typ mismatched.
I don't get what you are saying. If the problem is if you type it wrong, that's the case with everything. I will make a demo program to show what I mean. 7K3KQ3NX just look at it
Thanks! I just copied the code to mine and it works! Thanks, random_god!
Make sure to study the code too, so that you know how it works.
Just left the sprite ones, but thanks for the help. I'll study it ASAP.

~SNIP~ Just left the sprite ones, but thanks for the help. I'll study it ASAP.
Sprites are pretty simple. If it's auto-scrolling, on the exact pixel when it reaches the edge of the screen you set the sprite. This is kinda hard to explain, so I will upload the key to a thing similar to this that I have made. KEY: QDV4338D (credit to GAME4SHOOTER because of the map part of the first section) so yay

~SNIP~ ~SNAP~ Just left the sprite ones, but thanks for the help. I'll study it ASAP.
Sprites are pretty simple. If it's auto-scrolling, on the exact pixel when it reaches the edge of the screen you set the sprite. This is kinda hard to explain, so I will upload the key to a thing similar to this that I have made. KEY: QDV4338D (credit to GAME4SHOOTER because of the map part of the first section) so yay
Thanks, random! EDIT: Litterally, I don't know how to use SPDEF.

~SNIP~ ~SNAP~ Just left the sprite ones, but thanks for the help. I'll study it ASAP.
Sprites are pretty simple. If it's auto-scrolling, on the exact pixel when it reaches the edge of the screen you set the sprite. This is kinda hard to explain, so I will upload the key to a thing similar to this that I have made. KEY: QDV4338D (credit to GAME4SHOOTER because of the map part of the first section) so yay
Thanks, random! EDIT: Litterally, I don't know how to use SPDEF.
SPDEF is pretty simple. It's just making a sprite number (at default, 0 is a strawberry) have a different sprite than normal. Like SPDEF 0,0,0,16,16 makes sprite definition number 0 a strawberry, like it already is. SPDEF 0,0,0,32,32 makes it a 32x32 square instead of 16x16, so you get the strawberry, orange, and 2 other 16x16 things in one sprite. If you did SPDEF 0,16,0,16,16 you would get the orange, since 16,0 is the coordinates on the sprite graphic screen of the orange. The first number is the sprite definition you want to change, 0-4095.

~SNIP~ ~SNAP~ Just left the sprite ones, but thanks for the help. I'll study it ASAP.
Sprites are pretty simple. If it's auto-scrolling, on the exact pixel when it reaches the edge of the screen you set the sprite. This is kinda hard to explain, so I will upload the key to a thing similar to this that I have made. KEY: QDV4338D (credit to GAME4SHOOTER because of the map part of the first section) so yay
Thanks, random! EDIT: Litterally, I don't know how to use SPDEF.
SPDEF is pretty simple. It's just making a sprite number (at default, 0 is a strawberry) have a different sprite than normal. Like SPDEF 0,0,0,16,16 makes sprite definition number 0 a strawberry, like it already is. SPDEF 0,0,0,32,32 makes it a 32x32 square instead of 16x16, so you get the strawberry, orange, and 2 other 16x16 things in one sprite. If you did SPDEF 0,16,0,16,16 you would get the orange, since 16,0 is the coordinates on the sprite graphic screen of the orange. The first number is the sprite definition you want to change, 0-4095.
And the sprites aren't showing for some reason. I don't know how to put them on the map, because there are "H", "F" and other things that I don't see on those DATA commands before the MAP. I just copied the code

~SNIP~ ~SNAP~ Just left the sprite ones, but thanks for the help. I'll study it ASAP.
Sprites are pretty simple. If it's auto-scrolling, on the exact pixel when it reaches the edge of the screen you set the sprite. This is kinda hard to explain, so I will upload the key to a thing similar to this that I have made. KEY: QDV4338D (credit to GAME4SHOOTER because of the map part of the first section) so yay
Thanks, random! EDIT: Litterally, I don't know how to use SPDEF.
SPDEF is pretty simple. It's just making a sprite number (at default, 0 is a strawberry) have a different sprite than normal. Like SPDEF 0,0,0,16,16 makes sprite definition number 0 a strawberry, like it already is. SPDEF 0,0,0,32,32 makes it a 32x32 square instead of 16x16, so you get the strawberry, orange, and 2 other 16x16 things in one sprite. If you did SPDEF 0,16,0,16,16 you would get the orange, since 16,0 is the coordinates on the sprite graphic screen of the orange. The first number is the sprite definition you want to change, 0-4095.
And the sprites aren't showing for some reason. I don't know how to put them on the map, because there are "H", "F" and other things that I don't see on those DATA commands before the MAP. I just copied the code
If you are talking about an enemy definition table, like BGTABLE, I didn't do that. I just hard-coded that in. Like this:
FOR I=0 TO LEN(MAP$)-1
 '[insert map display stuff here]
 IF ASC(MID$(MAP$,I,1))>=ASC("A") THEN
  SPSET 1,512,SPRITE(MID$(MAP$,I,1)) OUT SP
  'Do other stuff here like positioning the sprite and setting variables
 ENDIF
NEXT
DEF SPRITE(V1)
 IF V1-ASC("A")==0 THEN RETURN '[Insert sprite number here]
 '...
END

~SNIP~ ~SNAP~ Just left the sprite ones, but thanks for the help. I'll study it ASAP.
Sprites are pretty simple. If it's auto-scrolling, on the exact pixel when it reaches the edge of the screen you set the sprite. This is kinda hard to explain, so I will upload the key to a thing similar to this that I have made. KEY: QDV4338D (credit to GAME4SHOOTER because of the map part of the first section) so yay
Thanks, random! EDIT: Litterally, I don't know how to use SPDEF.
SPDEF is pretty simple. It's just making a sprite number (at default, 0 is a strawberry) have a different sprite than normal. Like SPDEF 0,0,0,16,16 makes sprite definition number 0 a strawberry, like it already is. SPDEF 0,0,0,32,32 makes it a 32x32 square instead of 16x16, so you get the strawberry, orange, and 2 other 16x16 things in one sprite. If you did SPDEF 0,16,0,16,16 you would get the orange, since 16,0 is the coordinates on the sprite graphic screen of the orange. The first number is the sprite definition you want to change, 0-4095.
And the sprites aren't showing for some reason. I don't know how to put them on the map, because there are "H", "F" and other things that I don't see on those DATA commands before the MAP. I just copied the code
If you are talking about an enemy definition table, like BGTABLE, I didn't do that. I just hard-coded that in. Like this:
FOR I=0 TO LEN(MAP$)-1
 '[insert map display stuff here]
 IF ASC(MID$(MAP$,I,1))>=ASC("A") THEN
  SPSET 1,512,SPRITE(MID$(MAP$,I,1)) OUT SP
  'Do other stuff here like positioning the sprite and setting variables
 ENDIF
NEXT
DEF SPRITE(V1)
 IF V1-ASC("A")==0 THEN RETURN '[Insert sprite number here]
 '...
END
Thanks again, random_god! EDIT: I tried that, works when I don't put "A","C" or "B" (Enemy SPTABLE definitions), because I only get a Subscript out of range in 0:69. Any way to solve this? If I can on my own, I'm posting how I could solve it. EDIT 2: I could solve it by putting the DEF I made a DEF for the enemy generating...where MAPREAD and MAPRENDER are, but I just get an error saying me: Type mismatch in 0:77(MID$:1). Help? I can solve it on my own anyway, but still need help if someone can.

~SHNIP~ Thanks again, random_god! EDIT: I tried that, works when I don't put "A","C" or "B" (Enemy SPTABLE definitions), because I only get a Subscript out of range in 0:69. Any way to solve this? If I can on my own, I'm posting how I could solve it. EDIT 2: I could solve it by putting the DEF I made a DEF for the enemy generating...where MAPREAD and MAPRENDER are, but I just get an error saying me: Type mismatch in 0:77(MID$:1). Help? I can solve it on my own anyway, but still need help if someone can.
I'm not actually sure what you're doing. If you could send a key, that would help.

~SHNIP~ Thanks again, random_god! EDIT: I tried that, works when I don't put "A","C" or "B" (Enemy SPTABLE definitions), because I only get a Subscript out of range in 0:69. Any way to solve this? If I can on my own, I'm posting how I could solve it. EDIT 2: I could solve it by putting the DEF I made a DEF for the enemy generating...where MAPREAD and MAPRENDER are, but I just get an error saying me: Type mismatch in 0:77(MID$:1). Help? I can solve it on my own anyway, but still need help if someone can.
I'm not actually sure what you're doing. If you could send a key, that would help.
Ok, then EDIT: Sorry for the long time it took to put the key. I'm writing it. KEY: REMOVED