Jump to content
IGNORED

Need help edditing this code for use with a 6x4 sprite


Cubwyn2600

Recommended Posts

Here is the program:

 

     rem ************************************************************************
     rem A project by Viggo Ö Waller 
     rem ************************************************************************

     set kernel_options no_blank_lines
     set tv pal
     set romsize 16k
     set optimization speed
     set optimization size
     set smartbranching on
     set optimization noinlinedata
     set optimization inlinerand

     playfield:
     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     X..............................X
     X...XXXXX.XXX.XXXXX.X....XXXX..X
     X.....X....X....X...X....X.....X
     X.....X....X....X...X....X.....X
     X.....X....X....X...X....XXX...X
     X.....X....X....X...X....X.....X
     X.....X....X....X...X....X.....X
     X.....X...XXX...X...XXXX.XXXX..X
     X..............................X
     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end

title
     COLUBK = $00
     COLUPF = $0E
     drawscreen
     if joy0fire || joy1fire then goto skiptitle
     goto title
skiptitle

     playfield:
     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     X..............................X
     X..............................X
     X...............................
     X...............................
     X...............................
     X...............................
     X..............................X
     X..............................X
     X..............................X
     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end


     COLUBK = $00

     missile0height = 4  : missile0y = 255
     NUSIZ0 = $00
     score = 00000 :  scorecolor = $0E


     const _P_Edge_Top = 11 
     const _P_Edge_Bottom = 88 
     const _P_Edge_Left = 1 
     const _P_Edge_Right = 153 


     
     AUDV0 = 0 : AUDV1 = 0 
    
     COLUP1 = $0E
     COLUP0 = $0E
     COLUPF = $0E

     player0:
     %0110
     %0110
     %1111
     %1010
     %1111
     %1001
end

     player0x = 77 : player0y = 53

__main

     if !joy0up then goto __Skip_Joy0_Up
     if player0y <= _P_Edge_Top then goto __Skip_Joy0_Up
     temp5 = (player0x-10)/4
     temp6 = (player0y-9)/8
     if temp5 < 34 then if pfread(temp5,temp6) then goto __Skip_Joy0_Up
     temp4 = (player0x-17)/4
     if temp4 < 34 then if pfread(temp4,temp6) then goto __Skip_Joy0_Up
     temp3 = temp5 - 1
     if temp3 < 34 then if pfread(temp3,temp6) then goto __Skip_Joy0_Up
     player0y = player0y - 1
__Skip_Joy0_Up

 

     if !joy0down then goto __Skip_Joy0_Down
     if player0y >= _P_Edge_Bottom then goto __Skip_Joy0_Down
     temp5 = (player0x-10)/4
     temp6 = (player0y)/8
     if temp5 < 34 then if pfread(temp5,temp6) then goto __Skip_Joy0_Down
     temp4 = (player0x-17)/4
     if temp4 < 34 then if pfread(temp4,temp6) then goto __Skip_Joy0_Down
     temp3 = temp5 - 1
     if temp3 < 34 then if pfread(temp3,temp6) then goto __Skip_Joy0_Down
     player0y = player0y + 1
__Skip_Joy0_Down


     if !joy0left then goto __Skip_Joy0_Left
     if player0x <= _P_Edge_Left then goto __Skip_Joy0_Left
     temp5 = (player0y-1)/8
     temp6 = (player0x-18)/4
     if temp6 < 34 then if pfread(temp6,temp5) then goto __Skip_Joy0_Left
     temp3 = (player0y-8)/8
     if temp6 < 34 then if pfread(temp6,temp3) then goto __Skip_Joy0_Left
     player0x = player0x - 1
__Skip_Joy0_Left


     if !joy0right then goto __Skip_Joy0_Right
     if player0x >= _P_Edge_Right then goto __Skip_Joy0_Right
     temp5 = (player0y-1)/8
     temp6 = (player0x-9)/4
     if temp6 < 34 then if pfread(temp6,temp5) then goto __Skip_Joy0_Right
     temp3 = (player0y-8)/8
     if temp6 < 34 then if pfread(temp6,temp3) then goto __Skip_Joy0_Right
     player0x = player0x + 1 
__Skip_Joy0_Right


     if joy0left then a = a - 1
     if joy0right then a = a + 1 


     if joy0left || joy0right then goto __skip_y_anim 

     if joy0up then b = b + 1
     if joy0down then b = b - 1

     if  b  = 0 then player0:
     %1001
     %0110
     %1111
     %0101
     %1111
     %1001
end

     if b = 5 then player0:
     %0110
     %0110
     %1111
     %0101
     %1111
     %1001
end


     if b = 15 then player0:
     %0110
     %0110
     %1111
     %1010
     %1111
     %1001
end

     if b = 20 then player0:
     %1001
     %0110
     %1111
     %1010
     %1111
     %1001
end 


__skip_y_anim

     if  a  = 0 then player0:
     %1001
     %0110
     %1111
     %0101
     %1111
     %1001
end


     if a = 5 then player0:
     %0110
     %0110
     %1111
     %0101
     %1111
     %1001
end

     if a = 15 then player0:
     %0110
     %0110
     %1111
     %1010
     %1111
     %1001
end

     if a = 20 then player0:
     %1001
     %0110
     %1111
     %1010
     %1111
     %1001
end

     if a = 0 then a = 10
     if a = 20 then a = 10

     if b = 0 then b = 10
     if b = 20 then b = 10


     drawscreen

__skipmove
     goto __main

 

 

 

Thanks for any help :) 

 

- Viggo

Edited by Cubwyn2600
Link to comment
Share on other sites

you didn't say what the problem is

 

the code looks like it's for 8x8 sprites

 

playfield pixels are 4x8 player pixels and

the playfield coordinates don't jibe with player coordinates

 

the player movement code does collision detection by converting player coordinates

to playfield pixels and checking to see if there's a playfield pixel in the way

 

it does the conversion by adding an offset to the player position and dividing by 4 (for x) or 8 (for y)

 

you probably want to adjust the offsets to compensate for the difference in the sprite dimensions

Edited by bogax
clarification
Link to comment
Share on other sites

On 2/24/2024 at 9:46 PM, bogax said:

you didn't say what the problem is

 

the code looks like it's for 8x8 sprites

 

playfield pixels are 4x8 player pixels and

the playfield coordinates don't jibe with player coordinates

 

the player movement code does collision detection by converting player coordinates

to playfield pixels and checking to see if there's a playfield pixel in the way

 

it does the conversion by adding an offset to the player position and dividing by 4 (for x) or 8 (for y)

 

you probably want to adjust the offsets to compensate for the difference in the sprite dimensions

And what should those variables be changed to fit my sprite? Also, thanks for the help really need it 😕

 

Edited by Cubwyn2600
Clarification
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...