? How To Make Multiple enemies generate. (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password
💀

How To Make Multiple enemies generate.

  • #1 ✎ 109 Z_E_R_O Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself I need to know how to make multiple enemies. Posted
  • #2 ✎ 282 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Easy. Just create a bunch of sprites and use a bunch of vars for their positions. Posted
  • #3 ✎ 282 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength FOR I=0 TO WHATEVER SPSET I,0 SPOFS I,EX[I],EY[I] NEXT 'Now do whatever to the X/Y arrays Posted
  • #4 ✎ 109 Z_E_R_O Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Thank you! Posted
  • #5 ✎ 109 Z_E_R_O Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself it says type mitchmatch on spofs Posted
  • #6 ✎ 282 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Maybe try this? VAR ENEMY_COUNT=25 DIM EX[ENEMY_COUNT] DIM EY[ENEMY_COUNT] VAR I 'declare vars like normal FOR I=0 TO ENEMY_COUNT-1 'This will set the coordinates of each sprite to a random position on-screen. EX[I]=RND(400) EY[I]=RND(240) NEXT WHILE TRUE 'People often prefer while loops for their game loops. This isn't really necessary here. FOR I=0 TO ENEMY_COUNT-1 INC EX[I],(RND(10)-RND(10)) 'Should generate random positive or negative numbers. There are probably better ways of doing this. INC EY[I],(RND(10)-RND(10)) SPSET I,0 SPOFS I,EX[I],EY[I] NEXT VSYNC WEND Also arrays can be declared with VAR instead of DIM. Variables can be declared with DIM too. Posted Edited by spaceturtles
  • #7 ✎ 109 Z_E_R_O Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself It worked thank you. Posted
  • #8 ✎ 282 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength
    It worked thank you.
    You're welcome.
    Posted
  • #9 ✎ 109 Z_E_R_O Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself So this Is a while after. But how would I make them react to the BG like I do the character throu bgcheck? Posted
  • #10 ✎ 282 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength You BGCHECK with their sprites, just like the character. You can cycle through all of them in one frame (one pass of the game loop) using a FOR loop. Posted
  • #11 ✎ 109 Z_E_R_O Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself
    You BGCHECK with their sprites, just like the character. You can cycle through all of them in one frame (one pass of the game loop) using a FOR loop.
    Thanks again!! Now the only situation I have is I'm trying to make their color separate and it won't budge.
    Posted
  • #12 ✎ 282 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength You're trying to color each sprite a different color and make certain sprites not move as in at all or on the bg (or is that something else?)? Posted
  • #13 ✎ 109 Z_E_R_O Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself I was just trying to make a different type of enemy. And I'm still getting the hang of arrays. I want multiple types of enemy with the same collision and movement. Posted
  • #14 ✎ 282 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength There are a few ways of doing this. One way is to use one multi-dimensional array (but separate arrays allow more unique attributes and can be easier to use at times because they can be resized) for all the enemies and one loop to manage them all. The following code uses multiple, single dimension arrays to create and manage multiple enemies of different types. DIM ESP%[10] 'Enemy sprite DIM EX%[10] 'Enemy X coord DIM EY%[10] 'Enemy Y coord DIM ETYPE%[10] 'Enemy AI/etc. type FOR I=0 TO 9 SPSET I,ESP%[I] 'Of course, you will have to set the array data. For instance ESP%[0] can be sprite 16 while ESP%[whatever] can be whatever other sprite. NEXT WHILE 1 'Main loop, can be whatever loop type FOR I=0 TO 9 SPOFS I,EX%[I],EY%[I] IF ETYPE%[I]==0 THEN 'Enemy type code such as AI etc. ELSEIF ETYPE%[I]==1 THEN 'Same thing, continue for how many types you want. Be sure to include the type in your array. ENDIF 'You can also do other conditionals for the sprite, X/Y, etc. NEXT 'Game code. WEND I'll post again later if you still need help with arrays. Posted
  • #15 ✎ 109 Z_E_R_O Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Thank you! Youve been really nice even though I spam you with questions. Everything is working now. Posted
  • #16 ✎ 282 spaceturtles Video Games I like to play video games! Hobbies Avatar Block I didn't change my avatar for 30 days. Website Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength No problem. Question "spam" is what keeps the forums alive, just as long as they aren't repetitive questions. Posted
  • #17 ✎ 69 seggiepants You can use SPFUNC to have sprites handle themselves, and use SPVAR for the sprite specific variables. This example doesn't have sprite or background interaction but maybe it will help. If you get it right you just set up the sprite and let it go. VAR MAXX = 400, MAXY = 240, I '0-6 = FRUIT DEF BOUNCE VAR X, Y, XDIR, YDIR SPOFS CALLIDX OUT X, Y XDIR = SPVAR(CALLIDX, 0) YDIR = SPVAR(CALLIDX, 1) INC X, XDIR INC Y, YDIR IF X < 0 OR X >= MAXX THEN SPVAR CALLIDX, O, XDIR * -1 ENDIF IF Y < 0 OR Y >= MAXY THEN SPVAR CALLIDX, 1, YDIR * -1 ENDIF SPOFS CALLIDX, X, Y END ACLS : PRINT "PRESS [B] TO EXIT" FOR I = 0 TO 13 SPSET I, I MOD 7 SPOFS I, RND(MAXX), RND(MAXY) SPVAR I, 0, RND(9) - 4 SPVAR I, 1, RND(9) - 4 SPFUNC I, "BOUNCE" NEXT I REPEAT CALL SPRITE VSYNC UNTIL (BUTTON() AND #B) != 0 Posted
  • #18 ✎ 109 Z_E_R_O Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Thank you 😁 I have a code working now. But I like yours too. Posted