Jump to content

Captain Spazer

Members
  • Posts

    169
  • Joined

  • Last visited

Everything posted by Captain Spazer

  1. Oooh, that makes it easier. Thanks friend. You helped me alot =)
  2. This is the way I do it: rem Makes for better randomization dim rand16 = x rem random location for generic monster if player1x<=5 then player1x=255 : player1y=255 : n=(rand&1) : player1y=rand if player1x>=140 then player1x=255 : player1y=255 : n=(rand&1) : player1y=rand if player1y<20 then player1x=255 : player1y=255 : n=(rand&1) : player1y=rand if player1y>80 then player1x=255 : player1y=255 : n=(rand&1) : player1y=rand rem makes the generic monster move depending on what n decides if n=0 then player1x=140 : n=2 if n=2 then _P1_L_R=_P1_L_R-0.25 if n=1 then player1x=5 : n=3 if n=3 then _P1_L_R=_P1_L_R+0.25 main drawscreen goto main
  3. Thanks. It's a bit tricky but I'll figure it out eventually. Basically from what I understand, I need dim _pf_x = t, dim _pf_y = u in order to check for the playfields x and y values, and do the same for my ball object, and if my ball object collides with the playfield the game would check the x and y values and if it's a hit then pfpixel _pf_x _pf_y off. Am I somewhat getting it? =)
  4. Generic question about games like breakout and the like. How do I go about making something like that? When a ball or missile collides with a pfpixel it turns off. Do I do something like this? I defined a wall like this: rem player1 wall pfpixel 30 1 on pfpixel 30 2 on pfpixel 30 3 on pfpixel 30 4 on pfpixel 30 5 on pfpixel 30 6 on pfpixel 30 7 on pfpixel 30 8 on
  5. I've hit another snag. In this game, when player1 is hit with missile0 it goes offscreen and gets a random y position and a semi random x position. Anyway, that's what's supposed to happen. But instead of going offscreen too determine x and y position it does it onscreen and it makes for a weird rolling effect on the enemy sprite, what did I do wrong here? It works for player 2 and player 3. The code that's glitchy. I know it's extremely big and clunky, but it was the only way I could make hit detection work for all 3 player sprites, and I'm out of variables. On a sidenote: Is there any tricks on using less variables? q=player2x-8 r=player2x+18 s=player2y+1 t=player2y-8 u=player3x-8 d=player3x+18 v=player3y+1 w=player3y-8 rem makes player1 move if n=0 then player1x=140 : n=2 if n=2 then _P1_L_R=_P1_L_R-0.25 if n=1 then player1x=5 : n=3 if n=3 then _P1_L_R=_P1_L_R+0.25 rem random location for player1 if player1x<=5 then player1x=255 : player1y=255 : n=(rand&1) : player1y=rand if player1x>=140 then player1x=255 : player1y=255 : n=(rand&1) : player1y=rand if player1y<20 then player1x=255 : player1y=255 : n=(rand&1) : player1y=rand if player1y>80 then player1x=255 : player1y=255 : n=(rand&1) : player1y=rand rem makes player2 move if o=0 then player2x=140 : o=2 if o=2 then _P2_L_R=_P2_L_R-0.50 if o=1 then player2x=5 : o=3 if o=3 then _P2_L_R=_P2_L_R+0.50 rem random location for player2 if player2x<=5 then player2x=255 : player2y=255 : o=(rand&1) : player2y=rand if player2x>=140 then player2x=255 : player2y=255 : o=(rand&1) : player2y=rand if player2y<20 then player2x=255 : player2y=255 : o=(rand&1) : player2y=rand if player2y>80 then player2x=255 : player2y=255 : o=(rand&1) : player2y=rand rem makes player3 move if p=0 then player3x=140 : p=2 if p=2 then _P3_L_R=_P3_L_R-1.00 if p=1 then player3x=5 : p=3 if p=3 then _P3_L_R=_P3_L_R+1.00 rem random location for player3 if player3x<=5 then player3x=255 : player3y=255 : p=(rand&1) : player3y=rand if player3x>=140 then player3x=255 : player3y=255 : p=(rand&1) : player3y=rand if player3y<20 then player3x=255 : player3y=255 : p=(rand&1) : player3y=rand if player3y>80 then player3x=255 : player3y=255 : p=(rand&1) : player3y=rand rem shoot player1 if collision(missile0,player1) && missile0y=player1y then player1x=254 : player1y=254 : j=0 : score=score+10 : c=c+1 if collision(missile0,player1) && missile0y=player1y+1 then player1x=254 : player1y=254 : j=0 : score=score+5 : c=c+1 if collision(missile0,player1) && missile0y=player1y+2 then player1x=254 : player1y=254 : j=0 : score=score+5 : c=c+1 if collision(missile0,player1) && missile0y=player1y+3 then player1x=254 : player1y=254 : j=0 : score=score+5 : c=c+1 if collision(missile0,player1) && missile0y=player1y+4 then player1x=254 : player1y=254 : j=0 : score=score+5 : c=c+1 if collision(missile0,player1) && missile0y=player1y+5 then player1x=254 : player1y=254 : j=0 : score=score+5 : c=c+1 if collision(missile0,player1) && missile0y=player1y+6 then player1x=254 : player1y=254 : j=0 : score=score+5 : c=c+1 if collision(missile0,player1) && missile0y=player1y+7 then player1x=254 : player1y=254 : j=0 : score=score+5 : c=c+1 if collision(missile0,player1) && missile0y=player1y+8 then player1x=254 : player1y=254 : j=0 : score=score+5 : c=c+1 if collision(missile0,player1) && missile0y=player1y-1 then player1x=254 : player1y=254 : j=0 : score=score+5 : c=c+1 if collision(missile0,player1) && missile0y=player1y-2 then player1x=254 : player1y=254 : j=0 : score=score+5 : c=c+1 if collision(missile0,player1) && missile0y=player1y-3 then player1x=254 : player1y=254 : j=0 : score=score+5 : c=c+1 if collision(missile0,player1) && missile0y=player1y-4 then player1x=254 : player1y=254 : j=0 : score=score+5 : c=c+1 if collision(missile0,player1) && missile0y=player1y-5 then player1x=254 : player1y=254 : j=0 : score=score+5 : c=c+1 if collision(missile0,player1) && missile0y=player1y-6 then player1x=254 : player1y=254 : j=0 : score=score+5 : c=c+1 if collision(missile0,player1) && missile0y=player1y-7 then player1x=254 : player1y=254 : j=0 : score=score+5 : c=c+1 if collision(missile0,player1) && missile0y=player1y-8 then player1x=254 : player1y=254 : j=0 : score=score+5 : c=c+1 This code works for player 2 & player 3: rem shoot player2 if missile0x>q && missile0x<r && missile0y<s && missile0y>t then player2x=255 : player2y=255 : j=0 : score=score+10 : c=c+1 rem shoot player3 if missile0x>u && missile0x<d && missile0y<v && missile0y>w then player3x=255 : player3y=255 : j=0 : score=score+50 : c=c+1 The entire code: Monster_Safari.bas
  6. Thanks for the tip, worked like a charm!
  7. I'm having some beginner issues with animating player0's sprite. The glitch is that when you push joy0up & joy0left, joy0up & joy0right, joy0down & joy0left or joy0down & joy0right the animation freezes. But if you just press joy0left, joy0right, joy0up, joy0down it works fine. What am I missing? f=f+1 if f=10 then player0: %11000000 %01000011 %00111100 %01101110 %01111010 %01011110 %10111101 %11000011 end if f=20 then player0: %00000011 %11000010 %00111100 %01110110 %01011110 %01111010 %10111101 %11000011 end if i=0 then REFP0=0 if i=1 then REFP0=8 if f=20 then f=0 if joy0right then f=f+1 : i=0 : _P0_L_R = _P0_L_R + 0.35 if joy0left then f=f+1 : i=1 : _P0_L_R = _P0_L_R - 0.35 if joy0up then f=f+1 : _P0_U_D = _P0_U_D + 0.35 if joy0down then f=f+1 : _P0_U_D = _P0_U_D - 0.35
  8. Thank you, it helped alot! Now, follow up question, how do I add in so that the sprite get wider?
  9. Thank you, always nice to see more ways of doing things =)
  10. I'm having a little bit of trouble with my multisprite game, I noticed sprites can't be flipped the normal way and I tried using NUSIZ3{3} = 1 But the sprite dosn't flip. What gives? rem makes the sprite bigger NUSIZ3=$07 rem makes the boar move if p=0 then player3x=140 : p=2 if p=2 then NUSIZ3{3} = 0 : _P3_L_R=_P3_L_R-1.00 if p=1 then player3x=5 : p=3 if p=3 then NUSIZ3{3} = 1 : _P3_L_R=_P3_L_R+1.00
  11. That's so cool, I'm gonna learn DPC+ someday. I did something like this with the multisprite kernel, it was a mathematical nightmare XD
  12. I figured out how to do collision detection with the multisprite kernel!

    1. accousticguitar

      accousticguitar

      Congrats, it ain't easy.

    2. jd_1138

      jd_1138

      Is the code a complex series of nested while loops that end up looking like a fractal design?

    3. Captain Spazer

      Captain Spazer

      Nah, once you realised how it works it was really childsplay. You just needed some variables that kept track of all the sprites x and y positions. I'd be glad to do a tutorial if anyones interested =)

  13. Major update. It seems to work perfect now, man that was a tough nut to crack. Anyway, ladies and gentlemen, this seems to be the way to do collision detection with the multisprite kernel. First, you need variables to keep track of the virtual sprites, like this: q=player2x-4 r=player2x+1 s=player2y+1 t=player2y-4 Put that in the main loop. Next is the code for the collision: if missile0x>q && missile0x<r && missile0y<s && missile0y>t then player2x=255 : player2y=255 And boom, there ya go =) Proof that this works: Multisprite collision.bin
  14. Well, I'm gonna start with DPC+ and see if it's any easier then the multisprite kernel. But at the moment I'm kind of stuck on grasping banking. Can I use any bank for anything or is each bank for certain stuff? Also, a question on the multisprite kernel: MY enemy sprites are 8x8 and stretched with nusiz#=05. Is there a way to calculate so that if missile0 is in within those parameters an enemy is hit? Kinda like this? "if missile0x=player2x+8 then player2x=255 : player2y=255 "if missile0x=player2x-8 then player2x=255 : player2y=255 "if missile0y=player2y+8 then player2x=255 : player2y=255 "if missile0y=player2y-8 then player2x=255 : player2y=255 if missile0x = player1x && missile0y=player1y then player1x=255 : player1y=255 if missile0x = player2x && missile0y=player2y then player2x=255 : player2y=255 if missile0x = player3x && missile0y=player3y then player1x=255 : player1y=255 EDIT: Actually, it kinda worked! I managed to get hit detection to work with the multisprite kernel! But only if you hit the enemy sprite dead center, any idea on how to expand so the hit detects no matter where the enemy sprite is hit? if missile0x = player1x && missile0y=player1y then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y+1 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y+2 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y+3 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y+4 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y+5 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y+6 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y+7 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y+8 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y-1 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y-2 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y-3 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y-4 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y-5 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y-6 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y-7 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y-8 then player1x=255 : player1y=255
  15. Multisprite coding is so hard!

  16. I'm trying out the multisprite kernel and it's super awesome. It's so neat that you can have alot of sprites just like real atari games =D However, I'm wondering about calculating collision, just how do you do it? EDIT: I've heard it's easier to use the DPC+ Kernel for multisprite collision detection. But I'm a bit intimidated. Is it hard to convert an existing project to work in DPC?
  17. A.I is extremely hard I think. Sure, making a predictable A.I that just follows the player around relentlessly like a bloodhound and that guns him down as soon as he is in the line of sight is easy, and boring. But what about an A.I that could do that, and turn tail and run if the situation was not favorable? The closest I've managed is to have a random counter going off once in a while that makes the A.I bob and weave and resume the hunt a moment later. So, any tips would be great =) Here is my generic A.I routine. It may be useful to someone =) rem a.i routine j=j+1 rem every second the a.i does something different if j=60 then i=(rand&7) : j=0 if i=0 && c=0 then player1x=player1x-1 : e=1 if i=1 && c=0 then player1x=player1x+1 : e=0 if i=2 && c=0 then player1y=player1y+1 if i=3 && c=0 then player1y=player1y-1 if i=4 && c=0 && k=0 then k=1 if i=5 && c=0 then player1x=player1x-1 : e=1 if i=6 && c=0 then player1x=player1x+1 : e=0 if i=7 && c=0 then player1y=player1y+1 rem shoot right if i=4 && k=1 && c=0 && e=0 then missile1x=player1x : missile1y=player1y : k=2 if i=4 && k=2 && c=0 then missile1x=missile1x+1 rem shoot left if i=4 && k=1 && c=0 && e=1 then missile1x=player1x : missile1y=player1y : k=3 if i=4 && k=3 && c=0 then missile1x=missile1x-1 if c=0 && player1y>80 then player1y=80 if c=0 && player1y<10 then player1y=10 if missile1x>135 then missile1x=255 : missile1y=255 : k=0 if player1x>135 then player1x=0 if player1x<0 then player1x=135
  18. Let me know what's good and bad about it. Reviews are always welcome. I need to learn what's good and not so I can make better games in the future =)
  19. Ahh, I should've known not to redraw in the mainloop. Stupid overlook on my side. Thanks for the assist!
  20. Yes, I kept that in, as a strategical maneuver, a way of showing off if you'r pro if you will, hehe =)
  21. I'm having some difficulties with getting the horizontal scrolling working. I can get the playfield to "flip" but not scroll, I'm trying to make the playfield scroll horizontal when joy0left and joy0right are used. What am I doing wrong? rem Generated 2016-08-23 17:58:56 by Visual bB Version 1.0.0.566 rem ********************************** rem *<filename> * rem *<description> * rem *<author> * rem *<contact info> * rem *<license> * rem ********************************** set kernel_options pfcolors no_blank_lines set smartbranching on pfhline 8 5 23 on dim rand16 = z player0x=80 : player0y=75 a=10 c=10 player1x=50 : player1y=75 main scorecolor=$44 if a=10 then player0: %01001000 %01111100 %11111110 %01111110 %00000111 %00000110 %00001010 %00010100 end if a=20 then player0: %10000010 %01111100 %11111110 %01111110 %00000111 %00000110 %00001010 %00010100 end COLUP0=$0E if b=0 then REFP0=0 if b=1 then REFP0=8 if c=10 then player1: %00111000 %00011000 %00011000 %00011000 %00011000 %00001000 %00011000 %00011000 end if c=20 then player1: %01100100 %00101100 %00111000 %00011010 %01111110 %01001000 %00011000 %00011000 end c=c+1 if c=30 then c=0 playfield: ................................ ................................ ................................ ................................ ................................ ................................ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX .X.X.X.X.X.X.X.X.X.X.X.X.X.X.X.X .X.X.X.X.X.X.X.X.X.X.X.X.X.X.X.X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end pfcolors: $f5 $f5 $f5 $43 $f5 $f5 $f5 $26 $24 $22 $D8 $22 end COLUBK=$A8 rem makes the goat headbut people if collision(player0,player1) && b=0 then d=1 if d=1 then e=2 : player1x=player1x+1 : player1y=player1y-1 if collision(player0,player1) && b=1 then d=2 if d=2 then e=2 : player1x=player1x-1 : player1y=player1y-1 rem checks if the human is out of bounds if d=1 && player1y=0 then score=score+10 : d=3 if d=2 && player1y=0 then score=score+10 : d=3 if d=1 && player1x=0 then score=score+10 : d=3 if d=2 && player1x=0 then score=score+10 : d=3 if d=1 && player1y=135 then score=score+10 : d=3 if d=2 && player1y=135 then score=score+10 : d=3 if d=3 then player1x=255 : player1y=255 rem control logistics if joy0left then b=1 : a=a+1 : pfscroll left if joy0right then b=0 : a=a+1 : pfscroll right if joy0right && d=0 then player1x=player1x-1 if joy0left && d=0 then player1x=player1x+1 if d=3 && joy0left then e=e+1 if d=3 && joy0right then e=e+1 if e=60 then d=0 : e=0 if a=30 then a=0 rem scrolling logics if playfieldpos <> 8 then goto __Skip_Draw temp5 = rand : temp6 = rand/2 if temp5 > temp6 then var44 = 0 : var45 = 0 : var46 = 0 : var47 = 0 : goto __Skip_Draw var44 = rand : var45 = rand : var46 = rand : var47 = rand __Skip_Draw drawscreen goto main Source: Billy Goat.bas
×
×
  • Create New...