Retro Lord Posted January 16, 2015 Share Posted January 16, 2015 (edited) I have a question about the pfpixel on/off. I have a playfield where I want the pfpixels 12-21horizontal and 2-9 vertical to be turned on if player0 is on the same place. The player is 8x7 so the sprite fits perfectly in 1x2 pfpixels. How do I do a check too see if player0 is on the pfpixels? I'm guessing something like this won't work? if player0x = pfpixel 3 12 then pfpixel 3 12 on Edited January 16, 2015 by Retro Lord Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted January 16, 2015 Share Posted January 16, 2015 See if this is helpful:atariage.com/forums/topic/122998-double-click-draw/#entry1487708 Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted January 16, 2015 Author Share Posted January 16, 2015 (edited) Hm, that was helpful, but still a bit confusing. From what I understand I need a dim for my player0. That would be : dim herox = e dim heroy = f And when the hero moves something like this? if !joy0up then _Bit1{1} = 0 : goto __Skip_Fire if _Bit1{1} then goto __Skip_Fire _Bit1{1} = 1 player0y=player0y-7 : pfpixel player0x player0y on__Skip_Fire Am I getting warm? =) Edited January 16, 2015 by Retro Lord Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted January 16, 2015 Author Share Posted January 16, 2015 Hmm...I'm getting something now. Sometimes when I press joy0up 2 vertical bars appear left and right of the playfield. Atleast it's something happening. Now if I can only figure out how to get it at the locations I want. Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted January 17, 2015 Author Share Posted January 17, 2015 Slowly but surely I'm beginning too understand I think while tinkering like Dr. Frankenstein, creating all kinds of horrors that wasn't meant to be. I have 1 major issue I can't get to work at all. I can't do a dimer for player0 x,y. I tried doing dim herox=x and dim heroy=y but I either end up with an error or the character won't move. What is the proper way of doing this with player? Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted January 17, 2015 Share Posted January 17, 2015 If you are talking about using fixed point variables, here are examples from the bB page: dim _P0_L_R = player0x.adim _P0_U_D = player0y.bdim _P1_L_R = player1x.cdim _P1_U_D = player1y.d Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted January 17, 2015 Author Share Posted January 17, 2015 Ahh, cheers! Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted January 17, 2015 Author Share Posted January 17, 2015 (edited) Okay, thanks to you Random Terrain I'm much closer to getting it to work now! =D Now I can atleast get pfpixels to get turned on and off, a bit random but stil. Sometimes I get 3 pfpixels next to eachothers, sometimes 5 or so, sometimes a complete line. What might be the cause do you think? Did I place something wrong? drawscreen if joy0up then pfpixel _P0_L_R _P0_U_D off drawscreen pfpixel _P0_L_R _P0_U_D flip drawscreen pfpixel _P0_L_R _P0_U_D flip if !joy0up then _Bit1{1} = 0 : goto __Skip_Fire if _Bit1{1} then goto __Skip_Fire _Bit1{1} = 1 _P0_U_D=_P0_U_D-8.00 __Skip_Fire if !joy0down then _Bit2{1} = 0 : goto __Skip_Fire2 if _Bit2{1} then goto __Skip_Fire2 _Bit2{1} = 1 _P0_U_D=_P0_U_D+8.00 __Skip_Fire2 if !joy0left then _Bit3{1} = 0 : goto __Skip_Fire3 if _Bit3{1} then goto __Skip_Fire3 _Bit3{1} = 1 _P0_L_R=_P0_L_R-8.00 __Skip_Fire3 if !joy0right then _Bit4{1} = 0 : goto __Skip_Fire4 if _Bit4{1} then goto __Skip_Fire4 _Bit4{1} = 1 _P0_L_R=_P0_L_R+8.00 __Skip_Fire4 SKIP goto main SOURCE - D&D Demo.bas Edited January 17, 2015 by Retro Lord Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted January 17, 2015 Share Posted January 17, 2015 See if this is what you want: d_and_d_demo_2015y_01m_16d_2305t.bas d_and_d_demo_2015y_01m_16d_2305t.bin Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted January 17, 2015 Author Share Posted January 17, 2015 That's neat! It's almost what I was going for, I'm trying to make it so that the pfpixels player0 has been on stays red. Looking at the code, I notice some new things that I'd like to ask about in order to better grasp how this works. Is the playfield required to be inverted for it to work? And this code I don't quite get. I understant the idea that it makes the pfpixel that player0 is currently on turn on. But how are the numbers determined and how come they are divided by 4 or 8? Is it due too the player moving 8 pixels up and down and 4 right and left? _PF_LR = (player0x-15)/4 _PF_UD = (player0y/8)-1 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted January 17, 2015 Share Posted January 17, 2015 That's neat! It's almost what I was going for, I'm trying to make it so that the pfpixels player0 has been on stays red. Try this: d_and_d_demo_2015y_01m_16d_2352t.bas d_and_d_demo_2015y_01m_16d_2352t.bin And this code I don't quite get. I understand the idea that it makes the pfpixel that player0 is currently on turn on. But how are the numbers determined and how come they are divided by 4 or 8? Is it due too the player moving 8 pixels up and down and 4 right and left? _PF_LR = (player0x-15)/4 _PF_UD = (player0y/8)-1 The coordinates of the sprites never match the playfield since they are so different. And the numbers need to change depending on the playfield resolution. Check out this post for one example: atariage.com/forums/topic/131795-pf-pixels-to-sprite-pixels/?p=1706951 Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted January 17, 2015 Author Share Posted January 17, 2015 Exactly what I was going for. Thank you for showing how too structure this out and teaching me how pfpixels work, you rock. =) Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted January 17, 2015 Author Share Posted January 17, 2015 I have another question. I could use a hint for how to calculate if player1 is next to player0 and if less then 5x/y a sound is played. I've tried all I could think of, so I believe I'm in the need to learn something completely new to handle this. This is as far as my basic understanding of these things go and it's no good: if player0x=player1x5 then o=10 So in short, how do I go about checking for player1x/y if it's next too player0x/y? Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted January 17, 2015 Share Posted January 17, 2015 Understanding that I'm not good at programming, this is one way do it: _ dim _My_Temp01 = [some variable] If player0x > player1x then _My_Temp01 = player0x - player1x : if _My_Temp01 < 5 then [sound code or gosub to sound code] : goto __Skip_Proximity If player1x > player0x then _My_Temp01 = player1x - player0x : if _My_Temp01 < 5 then [sound code or gosub to sound code] : goto __Skip_Proximity If player0y > player1y then _My_Temp01 = player0y - player1y : if _My_Temp01 < 5 then [sound code or gosub to sound code] : goto __Skip_Proximity If player1y > player0y then _My_Temp01 = player1y - player0y : if _My_Temp01 < 5 then [sound code or gosub to sound code] __Skip_Proximity __ Here is another way: _ dim _My_Temp01 = [some variable] If player0x > player1x then _My_Temp01 = player0x - player1x : gosub __Check_Proximity If player1x > player0x then _My_Temp01 = player1x - player0x : gosub __Check_Proximity If player0y > player1y then _My_Temp01 = player0y - player1y : gosub __Check_Proximity If player1y > player0y then _My_Temp01 = player1y - player0y : gosub __Check_Proximity __Proximity_Check_Done [The following code would be outside of your main loop] __Check_Proximity if _My_Temp01 > 4 then return [sound code goes here] pop : goto __Proximity_Check_Done __ Here is a third way: _ dim _My_Temp01 = [some variable] If player0x > player1x then _My_Temp01 = player0x - player1x : gosub __Check_Proximity : goto __Skip_X_Check _My_Temp01 = player1x - player0x : gosub __Check_Proximity __Skip_X_Check If player0y > player1y then _My_Temp01 = player0y - player1y : gosub __Check_Proximity : goto __Proximity_Check_Done _My_Temp01 = player1y - player0y : gosub __Check_Proximity __Proximity_Check_Done [The following code would be outside of your main loop] __Check_Proximity if _My_Temp01 > 4 then return [sound code goes here] pop : goto __Proximity_Check_Done Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted January 17, 2015 Author Share Posted January 17, 2015 Ah, cheers for explaining! I think I got it =) Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted January 17, 2015 Author Share Posted January 17, 2015 Hm, I'm experimenting with this code but I always get an error message. Do I need to setup _My_Temp01 anywhere ellse then in this line of code? If player0x > player1x then _My_Temp01 = player0x - player1x : if _My_Temp01 < 5 then m=10 : goto __Skip_Proximity If player1x > player0x then _My_Temp01 = player1x - player0x : if _My_Temp01 < 5 then m=10 : goto __Skip_Proximity If player0y > player1y then _My_Temp01 = player0y - player1y : if _My_Temp01 < 5 then m=10 : goto __Skip_Proximity If player1y > player0y then _My_Temp01 = player1y - player0y : if _My_Temp01 < 5 then m=10 __Skip_Proximity Entire source: rem CODE INSPIRED BY Atarius Maximus at http://www.atariage.com/forums/index.php?showtopic=109288 include div_mul.asm TITLE playfield: ..XX..XXX.XXX.XX..XXX.XXX..XX... ..X.X.XX..XXX.X.X.X.X.X.X..X.... ..XX..X.X.X.X.XXX.XXX.X.X.XX.... ................................ ..............XXX............... ..............X.X............... ..............X.X............... ................................ XX..X.X.XXX.XX..XXX.XXX.XXX..XX. X.X.X.X.X.X.X.X.XX..X.X.X.X..X.. XX..XXX.X.X.XXX.XXX.XXX.X.X.XX.. end COLUPF=rand drawscreen if joy0fire goto charselect goto TITLE charselect player0x=81 : player0y=49 if j=0 then COLUP0=$2E if j=1 then COLUP0=$AE if j=2 then COLUP0=$52 COLUPF=rand if j=0 then player0: %00000000 %00101000 %00101000 %00010000 %01111000 %01000000 %01010000 %01010000 end if j=1 then player0: %00000000 %01111000 %01010000 %01010000 %01111000 %01000000 %00010000 %01011000 end if j=2 then player0: %00000000 %00101000 %00101000 %00010000 %01111000 %01000000 %01010000 %00010000 end playfield: ................................ ................................ ................................ ..............XXXXXX............ ..............X....X............ XXXXXXXXXXXXXXX....XXXXXXXXXXXXX ..............X....X............ ..............XXXXXX............ ................................ ................................ ................................ end drawscreen if joy0up then j=0 if joy0down then j=1 if joy0left then j=2 if joy0up && joy0fire then goto START : COLUPF=rand if joy0down && joy0fire then goto START : COLUPF=rand if joy0left && joy0fire then goto START : COLUPF=rand goto charselect START dim _Bit0_JoyU = a dim _Bit1_JoyD = a dim _Bit2_JoyL = a dim _Bit3_JoyR = a dim _PF_LR = f dim _PF_UD = g dim _classes = j player0x = 76 player0y = 72 missile0x=120 missile0y=60 player1x=rand player1y=rand scorecolor=$0E pfscorecolor = rand const pfscore=1 pfscore1 = 21 pfscore2 = 255 _PF_LR = (player0x-15)/4 _PF_UD = (player0y/8)-1 rem POSSIBLY INEFFICIENT CODE, SEPARATE COLOR INFO FOR EACH FRAME... player1: %00000000 %00101000 %00111100 %00011000 %00111000 %00000100 %00111000 %00011000 end playfield: ................................ ..........XXXXX..XXXXX.......... ..........X..........X.......... ..........X..........X.......... ..........X..........X.......... ..........X..........X.......... ..........X..........X.......... ..........X..........X.......... ..........X..........X.......... ..........XXXXX..XXXXX.......... ................................ end __Main_Loop rem Missile0 = spikhal rem player1 = drake rem missile1= missile0height=7 NUSIZ0=$20 if j=0 then COLUP0=$2E if j=1 then COLUP0=$AE if j=2 then COLUP0=$52 if collision(player0,missile1) then goto PIT ballheight = 7 CTRLPF = $21 h=h+1 If player0x > player1x then _My_Temp01 = player0x - player1x : if _My_Temp01 < 5 then m=10 : goto __Skip_Proximity If player1x > player0x then _My_Temp01 = player1x - player0x : if _My_Temp01 < 5 then m=10 : goto __Skip_Proximity If player0y > player1y then _My_Temp01 = player0y - player1y : if _My_Temp01 < 5 then m=10 : goto __Skip_Proximity If player1y > player0y then _My_Temp01 = player1y - player0y : if _My_Temp01 < 5 then m=10 __Skip_Proximity rem Walk if n > 0 then AUDV0 = 15 : AUDC0 = 1 : AUDF0 = 5 : n = n - 1: if n = 0 then AUDV0 = 0 rem Dragon if m > 0 then AUDV0 = 15 : AUDC0 = 2 : AUDF0 = 10 : m = m - 1: if m = 0 then AUDV0 = 0 rem Pit if p > 0 then AUDV0 = 15 : AUDC0 = 3 : AUDF0 = 13 : p = p - 1: if p = 0 then AUDV0 = 0 if h=255 then pfscore2=pfscore2/4 : h=0 if player0x<60 then player0x=60 : _PF_LR = _PF_LR + 1 if missile1x<60 then missile1x=rand if player1x<60 then player1x=rand if player0x>96 then player0x=96 : _PF_LR = _PF_LR - 1 if missile1x>96 then missile1x=rand if player1x>96 then player1x=rand if player0y<24 then player0y=24 : _PF_UD = _PF_UD + 1 if missile1y<24 then missile1y=rand if player1y<24 then player1y=rand if player0y>72 then player0y=72 : _PF_UD = _PF_UD - 1 if missile1y>72 then missile1y=rand if player1y>72 then player1y=rand COLUP1=$00 missile1height=8 if !joy0up then _Bit0_JoyU{0} = 0 : goto __Skip_Fire if _Bit0_JoyU{0} then goto __Skip_Fire _Bit0_JoyU{0} = 1 player0y = player0y - 8 _PF_UD = _PF_UD - 1 : n=10 __Skip_Fire if !joy0down then _Bit1_JoyD{1} = 0 : goto __Skip_Fire2 if _Bit1_JoyD{1} then goto __Skip_Fire2 _Bit1_JoyD{1} = 1 player0y = player0y + 8 _PF_UD = _PF_UD + 1 : n=10 __Skip_Fire2 if !joy0left then _Bit2_JoyL{2} = 0 : goto __Skip_Fire3 if _Bit2_JoyL{2} then goto __Skip_Fire3 _Bit2_JoyL{2} = 1 player0x = player0x - 4 _PF_LR = _PF_LR - 1 : n=10 __Skip_Fire3 if !joy0right then _Bit3_JoyR{3} = 0 : goto __Skip_Fire4 if _Bit3_JoyR{3} then goto __Skip_Fire4 _Bit3_JoyR{3} = 1 player0x = player0x + 4 _PF_LR = _PF_LR + 1 : n=10 __Skip_Fire4 rem 12-21 across rem 3-9 vertical if joy0fire then pfpixel _PF_LR _PF_UD off : goto __Skip_PF pfpixel _PF_LR _PF_UD on __Skip_PF drawscreen goto __Main_Loop PIT player0x=80 : player0y=20 missile0x=200 : missile0y=200 player1x=200 : player1y=200 missile1x=200 : missile1y=200 ballx=200 : bally=200 fall COLUP0=rand playfield: ................................ ................................ ................................ XXXXXXXXX..............XXXXXXXXX XXXXXXXXX..............XXXXXXXXX XXXXXXXXX..............XXXXXXXXX XXXXXXXXX..............XXXXXXXXX XXXXXXXXX..............XXXXXXXXX XXXXXXXXX..............XXXXXXXXX XXXXXXXXX..............XXXXXXXXX XXXXXXXXX..............XXXXXXXXX end drawscreen player0y=player0y+1 if player0y>90 then player0y=200 : player0x=200 if joy0down then reboot goto fall Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted January 17, 2015 Share Posted January 17, 2015 Yeah, dim _My_Temp01 = some variable. [i just updated my other post.] Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted January 17, 2015 Author Share Posted January 17, 2015 (edited) Ah okay. So this would be a correct dim? dim _My_Temp01 = k Edited January 17, 2015 by Retro Lord Quote Link to comment Share on other sites More sharing options...
bogax Posted January 17, 2015 Share Posted January 17, 2015 I have another question. I could use a hint for how to calculate if player1 is next to player0 and if less then 5x/y a sound is played. I've tried all I could think of, so I believe I'm in the need to learn something completely new to handle this. This is as far as my basic understanding of these things go and it's no good: if player0x=player1x5 then o=10 So in short, how do I go about checking for player1x/y if it's next too player0x/y? Suppose playerx and playery are both 8 x 8 pixel boxes and the player position is the upper right corner of the box. The left edge of player0 is at the player0x position the right edge of a player0 is at player0x + 7 If the player1x position is less than player0x + 7 + 5 the left edge of player1 will be within 5 pixels of the right edge of player0 Likewise, if player1x is greater than player0x - 7 - 5 then the player1 right edge wiil be within 5 pixels of the left edge of player0 (-5 is the 5 pixel gap to the left of the player0x position, -7 is where the player1x position would be relative to player1's right edge) So if player1x is greater than player0x - 12 or less than player0x + 12 then player1x is within 5 pixels of player0 If we take the player1 position to be 0 then player0 must be greater than 24 or less than 0 In 8 bit binary, "less than 0" is greater than 24 as long as it's not 256 - 24 = 232 less than 0 (256 is 0) ie 0 - 232 = 24 So if (player1 - player0 - 12) < 24 then player1 is within 5 pixels of player0 That's just an example. The details will depend on your sprites and how the kernel you're using works. Here's some example code. player0: %11111111 %11111111 %11111111 %11111111 %11111111 %11111111 %11111111 %11111111 end player1: %11111111 %11111111 %11111111 %11111111 %11111111 %11111111 %11111111 %11111111 end player0x = 60 player1x = 100 player0y = 40 player1y = 40 scorecolor = $1A loop if !joy0fire then skip if p then p = 0 else p = 1 skip if p then P1 f = (l ^ $F0) | SWCHA : l = SWCHA if !f{4} then player0y = player0y - 1 if player0y < 1 then player0y = 80 if !f{5} then player0y = player0y + 1 if player0y > 80 then player0y = 1 if !f{6} then player0x = player0x - 1 if player0x < 16 then player0x = 150 if !f{7} then player0x = player0x + 1 if player0x > 150 then player0x = 16 goto draw P1 if joy0up then player1y = player1y - 1 if player1y < 1 then player1y = 80 if joy0down then player1y = player1y + 1 if player1y > 80 then player1y = 1 if joy0left then player1x = player1x - 1 if player1x < 16 then player1x = 150 if joy0right then player1x = player1x + 1 if player1x > 150 then player1x = 16 draw temp1 = player0x + 12 - player1x temp2 = player0y + 12 - player1y if temp1 < 25 && temp2 < 25 then COLUP0 = $42 : COLUP1 = $74 else COLUP0 = $36 : COLUP1 = $B2 drawscreen goto loop Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted January 17, 2015 Author Share Posted January 17, 2015 My sprites are 8x4, too match the pfpixels. So if I understand the math that would be +3 ninstead of +7 if it was 8x8 in size? Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted January 17, 2015 Share Posted January 17, 2015 Ah okay. So this would be a correct dim? dim _My_Temp01 = k Right: randomterrain.com/atari-2600-memories-batari-basic-commands.html#dim Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted January 18, 2015 Author Share Posted January 18, 2015 Okay, hm. I still get a syntax error. Man this is difficult. I did the dim: dim _dragon_xpos = k And I added: If player0x > player1x then _dragon_xpos = player0x - player1x : if _dragon_xpos < 5 then m=10 : goto __Skip_Proximity If player1x > player0x then _dragon_xpos = player1x - player0x : if _dragon_xpos < 5 then m=10 : goto __Skip_Proximity __Skip_Proximity Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted January 18, 2015 Share Posted January 18, 2015 Attach your .bas file. Quote Link to comment Share on other sites More sharing options...
Retro Lord Posted January 18, 2015 Author Share Posted January 18, 2015 I'm guessing I put it in the wrong position or some other thing that I overlooked but can't figure out =/ Download - d_and_d_demo_2015y_01m_16d_2352t.bas Quote Link to comment Share on other sites More sharing options...
bogax Posted January 18, 2015 Share Posted January 18, 2015 My sprites are 8x4, too match the pfpixels. So if I understand the math that would be +3 ninstead of +7 if it was 8x8 in size? In the x direction, correct player0: %00001111 %00001111 %00001111 %00001111 %00001111 %00001111 %00001111 %00001111 end player1: %00001111 %00001111 %00001111 %00001111 %00001111 %00001111 %00001111 %00001111 end player0x = 60 player1x = 100 player0y = 40 player1y = 40 scorecolor = $1A loop if !joy0fire then skip if p then p = 0 else p = 1 skip if p then P1 f = (l ^ $F0) | SWCHA : l = SWCHA if !f{4} then player0y = player0y - 1 if player0y < 1 then player0y = 80 if !f{5} then player0y = player0y + 1 if player0y > 80 then player0y = 1 if !f{6} then player0x = player0x - 1 if player0x < 16 then player0x = 150 if !f{7} then player0x = player0x + 1 if player0x > 150 then player0x = 16 goto draw P1 if joy0up then player1y = player1y - 1 if player1y < 1 then player1y = 80 if joy0down then player1y = player1y + 1 if player1y > 80 then player1y = 1 if joy0left then player1x = player1x - 1 if player1x < 16 then player1x = 150 if joy0right then player1x = player1x + 1 if player1x > 150 then player1x = 16 draw temp1 = player0x + 8 - player1x temp2 = player0y + 12 - player1y if temp1 < 17 && temp2 < 25 then COLUP0 = $42 : COLUP1 = $74 else COLUP0 = $36 : COLUP1 = $B2 drawscreen goto loop proximity_example.bin Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.