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:
Ok, this is a fairly simple problem. You put MID$(MAP$,I#,1) The problem with this is that MAP$ is an array, not one string. In the FOR loop you go FOR I#=0 TO LEN(MAP$)-1 because LEN returns the number of elements in the array. But in MID$, it returns a section of a string. If you try to make MID$ read a section of an array, it won't work, even if it's a string array. You would need to tell it where in the array to look at:
IF ASC(MID$(MAP$[I#],J#,1))>=ASC("A") THEN '...
This way it gets a single string rather than a whole array. EDIT: Also, when looking through the map, we had 2 loops, remember? We need these for the enemies, too. One for X and one for Y. You already know how to do this.
FOR I#=0 TO LEN(MAP$)-1
 FOR J#=0 TO LEN(MAP$[I#])-1
  IF ASC(MID$(MAP$[I#],J#,1)>=ASC("A") THEN '...
 NEXT
NEXT

That's what I've learned now:
FOR I#=0 TO LEN (MAP$)-1
 FOR J#=0 TO LEN(MAP$[I#])-1
  IF ASC(MID$(MAP$[I#],J#,1)>=ASC("A") THEN '...
 NEXT
NEXT
This assigns the sprite's X and Y, isn't it?
Also, when looking through the map, we had 2 loops, remember? We need these for the enemies, too. One for X and one for Y. You already know how to do this.
IF ASC(MID$(MAP$[I#],J#,1))>=ASC("A") THEN '...
This searches the string I put on the map, in example the "A" string, it searches for it and it places the sprite wanted for it.

That's what I've learned now:
FOR I#=0 TO LEN (MAP$)-1
 FOR J#=0 TO LEN(MAP$[I#])-1
  IF ASC(MID$(MAP$[I#],J#,1)>=ASC("A") THEN '...
 NEXT
NEXT
This assigns the sprite's X and Y, isn't it?
Also, when looking through the map, we had 2 loops, remember? We need these for the enemies, too. One for X and one for Y. You already know how to do this.
IF ASC(MID$(MAP$[I#],J#,1))>=ASC("A") THEN '...
This searches the string I put on the map, in example the "A" string, it searches for it and it places the sprite wanted for it.
Well to position the sprite you need to use SPOFS and judge where to put it based off of where in the string array it was found. But you also probably want a variable system or spawn the sprites only when they come on screen so you don't end up with the enemies continuing to appear after they have already spawned. I'm not sure how you'll do this, as you hinted you want it to change scrolling direction. The way I would do it is have the sprite only spawn at the top of the screen and then it can't spawn any more, but if the scrolling direction changes, that doesn't work well. The only way I can think of is having some sort of variable system, which I don't know how to do.

Ok, this is a fairly simple problem. You put MID$(MAP$,I#,1) The problem with this is that MAP$ is an array, not one string. In the FOR loop you go FOR I#=0 TO LEN(MAP$)-1 because LEN returns the number of elements in the array. But in MID$, it returns a section of a string. If you try to make MID$ read a section of an array, it won't work, even if it's a string array. You would need to tell it where in the array to look at:
IF ASC(MID$(MAP$[I#],J#,1))>=ASC("A") THEN '...
This way it gets a single string rather than a whole array. EDIT: Also, when looking through the map, we had 2 loops, remember? We need these for the enemies, too. One for X and one for Y. You already know how to do this.
FOR I#=0 TO LEN(MAP$)-1
 FOR J#=0 TO LEN(MAP$[I#])-1
  IF ASC(MID$(MAP$[I#],J#,1)>=ASC("A") THEN '...
 NEXT
NEXT
It's been a while for now, but I had tried to resolve this problem months ago, and then lost inspiration of the project because of this. When I put, for example, "A" string, and the following code you put above, simply comes with the following error: Subscript out of range in 0:66 Help? I don't want to push you too much, but this error pops up every time when I run the program.

Where did you put "A"? Also, how are your FOR loops structured? Are you going FOR I#=0 TO LEN(MAP$)-1 or FOR I#=0 TO LEN(MAP$)? Let me see the code stuff (screenshot of 0:66 and the stuff around it)

Where did you put "A"? Also, how are your FOR loops structured? Are you going FOR I#=0 TO LEN(MAP$)-1 or FOR I#=0 TO LEN(MAP$)? Let me see the code stuff (screenshot of 0:66 and the stuff around it)
Here are the images you want

You need to set BGSCREEN. The bg tiles you are trying to place are outside of the BG screen, because it's small and your map is big. Basically BGSCREEN works like this :
BGSCREEN LAYER,WIDTH,HEIGHT'Width and height are in BG tiles.

You need to set BGSCREEN. The bg tiles you are trying to place are outside of the BG screen, because it's small and your map is big. Basically BGSCREEN works like this :
BGSCREEN LAYER,WIDTH,HEIGHT'Width and height are in BG tiles.
I mean, to generate enemies EDIT: I found a way to generate the enemies properly, I just made a tile-check.
DEF MAPRENDER
 FOR I#=0 TO LEN(MAP$)-1
  FOR J#=0 TO LEN(MAP$[I#])-1
  VAR NS
   IF ASC(MID$(MAP$[I#],J#,1))>=ASC("A") THEN SPSET 1213 OUT NS ELSE BGPUT 0,J#,I#,BGTABLE[(ASC(MID$(MAP$[I#],J#,1)))-48]
I just need sprite positioning and that's all.

The bug was occuring where it was placing the BG tile, on 0:64

The bug was occuring where it was placing the BG tile, on 0:64
So, I need to put it BEFORE the BG reading loop occurs? Nvm, it was the "A" tile that was causing problems. It is because it wasn't checking where the tile was, so when it thinks the "A" tile is part of the BGTABLE, but doesn't found a tile named "A", I made a check to tell the reader that it was a sprite tile.

What? You just need to set the BGSCREEN before doing BG stuff.

What? You just need to set the BGSCREEN before doing BG stuff.
Yeah, I had set it yesterday before your post

Uhh ok

Uhh ok
But I have problems with enemy positioning, so here is the error I'm having: I've been looking and digging around the code of my game, but still, my enemy sprite is still in the superior part: I just want my enemy to be at the center of the map, here is the data of the map: So, I actually don't know how to center the sprite, but if I put SPOFS after setting the sprite, comes with this error: I actually need some help on this part. I actually don't need help (well, not sure) with the bullets.

Well you need to actually position the sprite. To do this, you use SPOFS. It's simple sprite functions 101. And the location would be the same as BGPUT, except multiplied by 16.

Well you need to actually position the sprite. To do this, you use SPOFS. It's simple sprite functions 101. And the location would be the same as BGPUT, except multiplied by 16.
Look, there is the complete code if you can't watch it in-depth. KEY: DK3NQ39X Steps to get the error: Run GB_UNFIX Remove the END command at the very first line of code on the program. Run it and then see what's the problem, I couldn't figure it on my own... I tried ASC, SPOFS J#,I#... And still, the same problem.

Yeah um you should try to only spawn the sprite once. It ends up spawning them all the way to your sprite limit and then SPSET returns -1 and breaks it. You probably want to spawn the sprites only exactly when they should come on screen, or on the first frame of the current map.

Yeah um you should try to only spawn the sprite once. It ends up spawning them all the way to your sprite limit and then SPSET returns -1 and breaks it. You probably want to spawn the sprites only exactly when they should come on screen, or on the first frame of the current map.
Yeah, I just want to get rid of that error when trying to positioning the sprite.

And the way to fix it is to spawn the enemies only once, or you'll run out of sprites.

And the way to fix it is to spawn the enemies only once, or you'll run out of sprites.
But if I'm trying to spawn 2 sprites?