UnderwareDESIGN

PlayBASIC => Show Case => Topic started by: LemonWizard on January 01, 2012, 03:30:37 AM

Title: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on January 01, 2012, 03:30:37 AM
Hey all.
Well as you all know by now , or should. I like to push things with playbasic, past the limits.
IT SHOULD be capable of running a game that's created in snes style.

For all you retro gamers out there, the wait is over.
I'm finally (after years of saying I can/will) creating a fully functional 2d sidescrolling system.

It will feature a comprehensive in game editor, and it will also feature sprite placement and tools for setting collision events.
Hopefully down the road it will have a trigger system and some kind of a scripting system, where you can add already made scripts as well for sprites.
Such as AI and paths.
I don't just plan on going half way either. This engine is going to be completely developed, into a fully functional game engine.
Which, should when completed be adaptable to build almost any type of game on. With a few adjustments of course.

So far the global variables that are the most important are the map sizes, and the sprite width and height.
The collision system uses 16*16 tiles, and right now it does not draw images as tiles but instead renders a large tiled image, from a file.

Basically the collision system lets you point and click where you want your "solids" to go. And the engine handles the rest. Simple.

Without further delay here is the screenshot.
I can't promise I'll be able to live up to even my own expectations Just recently I had a nasty hard drive error. Making backups tonight to be safe!!

Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on January 01, 2012, 01:11:01 PM
Update and backup of code:

[pbcode]
; PROJECT : Castle Crush
; AUTHOR  : NA
; CREATED : 12/27/2011
; EDITED  : 1/1/2012
; ---------------------------------------------------------------------
castle=loadnewfximage("castlecrush.png")
imagemaskcolour castle, rgb(255, 0, 255)
mode=loadnewfximage("mode.png")
HEIGHT=getimageheight(castle)
WIDTH=getimagewidth(castle)
save=loadnewfximage("save.png")
playmode=loadnewfximage("Playmode.png")
grid=false
backdrop=loadnewfximage("castle.png")
levelname$="castle crush"
wall=loadnewfximage("wall.png")
wallx=0
wally=12256-200



dim dixieright(18)
dim dixieleft(18)
for temp=1 to 18
   dixieright(temp)=loadnewfximage("Sprites/dixieframe"+str$(temp)+".bmp")
   imagemaskcolour dixieright(temp), rgb(255,255, 255)
   dixieleft(temp)=newfximage(55, 45)
   copyimage dixieright(temp), dixieleft(temp)
   mirrorimage dixieleft(temp), 1, 0
next temp


dim dixiejumpright(4)
dim dixiejumpleft(4)

for temp=1 to 4
   dixiejumpright(temp)=loadnewfximage("Sprites/dixiejump"+str$(temp)+".bmp")
   imagemaskcolour dixiejumpright(temp), rgb(255, 255, 255)
   dixiejumpleft(temp)=newfximage(55, 74)
   copyimage dixiejumpright(temp), dixiejumpleft(temp)
   mirrorimage dixiejumpleft(temp), 1, 0
   imagemaskcolour dixiejumpleft(temp), rgb(255, 255, 255)
   next temp
   


dixieaction=1
jumpframe=1

   

SCROLLX=0
SCROLLY=11776
MAPWIDTH=roundup(WIDTH/16)
MAPHEIGHT=roundup(HEIGHT/16)
dim map(MAPWIDTH, MAPHEIGHT)
spritewidth=55
spriteheight=45
dixieframe=1
frametimer=timer()+30

type solid_tile
   x1
   y1
   x2
   y2
endtype
   

dim solids(MAPWIDTH, MAPHEIGHT) as solid_tile
read=false
if fileexist("C:\\castlemap.txt") then read=true

IF READ=TRUE
readfile "C:\\castlemap.txt", 1
rendertoimage castle
for tempx=1 to MAPWIDTH
   for tempy=1 to MAPHEIGHT
      map(tempx, tempy)=readint(1)
      solids(tempx, tempy).x1=readint(1)
      solids(tempx, tempy).y1=readint(1)
      solids(tempx, tempy).x2=readint(1)
      solids(tempx, tempy).y2=readint(1)
      x1=solids(tempx, tempy).x1
      y1=solids(tempx, tempy).y1
      x2=solids(tempx, tempy).x2
      y2=solids(tempx, tempy).y2
      ink rgb(0, 0, 255)
      box x1, y1, x2, y2, 0
   next tempy
next tempx
closefile 1

   ENDIF
      

myimage=newfximage(640, 480)
imagemaskcolour myimage, rgb(255, 0, 255)
MODE$="View"


rendertoimage castle

if grid=true
for tempx=1 to WIDTH/16
   for tempy=1 to HEIGHT/16
      ink rgb(255,255, 255)
      box (tempx-1)*16, (tempy-1)*16, tempx*16, tempy*16, 0
   next tempy
next tempx   
endif
   
      
wallspeed=25
charx=400
chary=12128
falling=false
walltimer=timer()+wallspeed


do
   
   
   
   
   if timer()>walltimer
      walltimer=timer()+wallspeed
   
   if falling=true
   if chary=>wally-spriteheight-1
      chary=wally-spriteheight-1
      landed=true
      falling=false
      onwall=true
   else
      onwall=false   
endif
endif   


   
      
      if jump=false
         if falling=false
            if onwall=true
               chary=chary-1
            endif
         endif
      endif
      
      wally=wally-1
      scrolly=scrolly-1      
      
      
   endif
   
   if mode$="playmode"
   if onwall=true
      
            ;pan camera down slowly
               if scrolly<wally-400
                  scrolly=scrolly+2
                  scrollimage backdrop, 0, -1
               else   
      scrolly=wally-400
            endif
      if scrolly>11776 then scrolly=11776
   endif   
   endif   
      

   


         

;draw map


;render to the map image
rendertoscreen


         
rendertoimage castle

x=mousex()
y=mousey()

if SCROLLX=>16
   amountx=roundup(SCROLLX/16)
   else amountx=1
endif
   ;top side same thing as above
if SCROLLY=>16
   amounty=roundup(SCROLLY/16)
else
   amounty=1
endif







moveright=true
moveleft=true

      


for tempx=amountx to 32  ;disable x scroll for this entirely for the right side
   for tempy=amounty to 30+amounty
      
      x=(tempx-1)*16
      y=(tempy-1)*16
      
      xdraw=x-SCROLLX
      ydraw=y-SCROLLY
      ink rgb(0, 255, 0)
      ;box x, y, x+16, y+16, 0
            
            ;check solid tiles below character
            
            
            
            ;check player on tile
                  
                  if map(tempx, tempy)=1       ;if the tile is solid, check against player collision         
                     
                     
               checkingx1=solids(tempx, tempy).x1
               checkingy1=solids(tempx, tempy).y1
               checkingx2=solids(tempx, tempy).x2
               checkingy2=solids(tempx, tempy).y2
               
               
                           
                           playerx1=charx
                           playery1=chary
                           playerx2=charx+spritewidth
                           playery2=chary+spriteheight
                           
                           if playerx2>checkingx1         ;the players x coordinates align
                           if playerx1<checkingx2                  
                                    if playery1<checkingy1 ;the players top edge is not past the top of the platform
                                 if playery2>checkingy1-2 ;the players bottom edge IS past the top of the platform-1 pixel
                                       landed=true
                                    endif
                                 endif
                           endif
                        endif
                              
                                       
                                 
                           
                              ;check for left and right sides
                  ;check left collision (Player is here --> ||Colliding with LEFT wall of object)

                                             
                     if playerx2>checkingx1-1
                        if playerx2<checkingx1+1
                           if playery2>checkingy1
                              if playery1<checkingy2
                                 moveright=false
                              else
                                 moveright=true
                              endif
                           endif
                        endif
                     endif
                                    
                                    ;check right collision
                     if playerx1>checkingx2-1
                        if playerx1<checkingx2+1
                           if playery2>checkingy1
                              if playery1<checkingy2
                                 moveleft=false
                              else
                                 moveleft=true
                              endif
                           endif
                        endif
                     endif
                                    
                     
                           
                           
                           
                           
                     endif
                     
                     
                  
                              
                                                                        
            
                              
            
            
            if mode$="Collision"         ;only place tiles if mode is collision
            
            
            
            
            
            if mouseinbox(xdraw, ydraw, xdraw+16, ydraw+16)
               if rightmousebutton()
                  charx=x
                  chary=y
               endif
               endif   
               
            
            
      if leftmousebutton()
         if mouseinbox(xdraw, ydraw,xdraw+16, ydraw+16)
            box x, y, x+16, y+16, 0
            map(tempx, tempy)=1
            solids(tempx, tempy).x1=x
            solids(tempx, tempy).y1=y
            solids(tempx, tempy).x2=x+16
            solids(tempx, tempy).y2=y+16
         endif
   endif
            endif   
            
      
      
   next tempy
next tempx

                        

                  if mode$="playmode"
                     if jump=false
               if landed=false
            
            ;handle character falling
                  if falling=true
                     chary=chary+2
                     if chary=>480/2         ;sloppy attempt at keeping the player centered on camera
                        scrolly=scrolly+2  
                        
                        scrollimage backdrop, 0, -1
                     endif
                        
                  endif
                  
                     
               
                     
               
               
               
               endif ;only execute character falling code if landed is false.
            endif         ;end the code for jumping
                  
                  
                     endif
                        
                     
                     
                              
                     
            ink rgb(0, 0, 255); blue

   
   ink rgb(255, 255, 255)
      


      for temp=1 to roundup(640/163)
         drawimage wall, (temp-1)*163, wally, 0
         next temp
         
         
      getimage myimage, 0+scrollx, 0+scrolly, 640+scrollx , 480+scrolly
      
      ;make sure it doesn't scroll past the left or right side too far
      if scrollx<=0 then scrollx=0
      ;if scrollx+640=>WIDTH then scrollx=WIDTH-640

      ;make sure it doesn't scroll past the top or bottom side too far
      if scrolly<=0 then scrolly=0
      if scrolly+480=>HEIGHT then scrolly=HEIGHT-480
   
         
         
         
      
      rendertoscreen
      ;box charx, chary, charx+16, chary+16, 0
      charx1=charx
      chary1=chary
      charx2=charx+spritewidth
      chary2=chary+spriteheight
      charx1=charx1-scrollx
      chary1=chary1-scrolly
      charx2=charx2-scrollx
      chary2=chary2-scrolly
      
      
      
      
      for tempx=1 to 2
         for tempy=1 to 2
            drawimage backdrop, (tempx-1)*320, (tempy-1)*256, 0
      next tempy
      next tempx   
         
            
      
      drawimage myimage, 0, 0, 1
      drawimage mode, 640, 100, 0
      drawimage save, 640, 200, 0
      drawimage playmode, 640, 300, 0
      
      ink rgb(0, 0, 255)      ;blue character
      ;box charx1, chary1, charx2, chary2, 1
      box charx1, chary1, charx2, chary2, 0
      
      if dixieaction=1
      if landed=true
      drawimage dixieright(dixieframe), charx1, chary1+16, 1
      else
            if jump=true   
      drawimage dixiejumpright(jumpframe), charx1, chary1-32, 1
      else
      drawimage dixiejumpright(4), charx1, chary1-32, 1
      endif
      endif
      endif
      
      if dixieaction=2
      if landed=true
      drawimage dixieleft(dixieframe), charx1, chary1+16, 1
      else
            if jump=true
      drawimage dixiejumpleft(jumpframe), charx1, chary1-32, 1   
      else
      drawimage dixiejumpleft(4), charx1, chary1-32, 1
      endif
      endif
      endif
               
            
      ink rgb(255, 255, 255) ;white
      
      
      
      
text 200, 500, "SCROLLY " +str$(Scrolly)+" --ROUNDED to tile index: "+str$(amounty)
text 200, 520, "SCROLLX " +str$(Scrollx)+" --ROUNDED to tile index: "+str$(amountx)
text 200, 540, "This is the result of WIDTH <> scroll X"+str$(WIDTH-(640+scrollx))+"and"+str$(WIDTH)
text 200, 560, "Playerx : "+str$(charx)+" Playery : "+str$(chary)

if mouseinbox(640, 100,  640+128, 164)
   if leftmousebutton()
      mode$="Collision"
   endif
endif

if mouseinbox(640, 300, 640+(128*3), 364)
   if leftmousebutton()
      mode$="playmode"
      falling=true
   endif
endif
      

   if mouseinbox(640, 200, 640+(128*2), 264)
      if leftmousebutton()
            
            writefile "C:/castlemap.txt", 1
            
            for tempx=1 to Mapwidth
               for tempy=1 to mapheight
                  writeint 1, map(tempx, tempy)
                  writeint 1, solids(tempx, tempy).x1
                  writeint 1, solids(tempx, tempy).y1
                  writeint 1, solids(tempx, tempy).x2
                  writeint 1, solids(tempx, tempy).y2
               next tempy
            next tempx
            closefile 1
                  
         
      endif
      endif   

      

;scrolling input




if leftkey()
   ;scrollx=scrollx-8
   dixieaction=2
   if timer()>frametimer
   dixieframe=dixieframe+1
   
   if dixieframe>16 then dixieframe=1
   frametimer=timer()+30
endif

if moveleft=true   
   if spacekey()
   charx=charx-4
else
   charx=charx-1
endif
      
endif

endif



      
if rightkey()
   ;scrollx=scrollx+8
   dixieaction=1
   if timer()>frametimer
   dixieframe=dixieframe+1
   
   if dixieframe>16 then dixieframe=1
   frametimer=timer()+30
   endif
   
   if moveright=true
   if spacekey()
      charx=charx+4
      else
   charx=charx+1
endif

endif

   

endif

      if mode$<>"playmode"
      
      if downkey()
         scrolly=scrolly+8
      endif
   
      if upkey()
      scrolly=scrolly-8
      endif

endif
   
         
         
               if mode$="playmode"
                  
                  
            if jump=false
            if upkey()
               if landed=true
            jump=true
            upforce=45
            jumpframetimer=timer()+600
      endif
endif
endif
   
      
            
         
         
         
            if jump=true
               
               
               chary=chary-2
               upforce=upforce-2
               scrolly=scrolly-2
               scrollimage backdrop, 0, 1
               if timer()>jumpframetimer
                  jumpframe=jumpframe+1
                  if jumpframe>4 then jumpframe=4
                  jumpframetimer=timer()+600
      endif
   endif   
         
         if jump=true
         if upforce=<0
            jump=false
            falling=true
            landed=false
            upforce=0
            endif
            endif   
            
            
            
            endif
               
            

            
      falling=true
      ;landed=false
      ;moveright=true
sync
cls rgb(0,0,0)
loop




function draw_blank_tiles()
for tempx=amountx to 20+amountx+1
   for tempy=amounty to 15+amounty+1
      
      x=(tempx-1)*32
      y=(tempy-1)*32
      
      xdraw=x-SCROLLX
      ydraw=y-SCROLLY

   
         
      
      ;tilenum=map(tempx, tempy)
      ;print "Tilenum is" +str$(tilenum)
      ;print "Press key to show image"
      ;waitkey
      ;waitnokey
      ;sync
         
         if tilenum=<0 then tilenum=1
         if tilenum=>101 then tilenum=100
         
      ;drawimage tiles(tilenum), xdraw, ydraw, 0
      
next tempy

      
         
               
               
   next tempx   
      rendertoscreen
drawimage timage, 0, 0, 0
endfunction


[/pbcode]


I am not sure if I want to upload a full demo yet. It isn't in completely working order the way I'd like.
IF ANY retro game fans want to help me with this project let me know. WE CAN build on this game engine together :D I'm sorry about the poor camera code. it was the only way I could break playbasic's tile scrolling limits without using scenes or cameras that are built into it's engine.
The player's X and Y coordinates are drawn by adding the scrollx and scrolly values to the calculation since drawing the player directly onto the castle image, OR making a copy of the castle image does NOT work. And the player MUST be drawn using world coordinates or collision will fail.



Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: ATLUS on January 01, 2012, 01:38:16 PM
looks very nice!
Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on January 02, 2012, 11:59:54 AM
Oh my god so I stayed up again all night tinkering with the engine.
I'm going to have some fun, creating a few non dkc2 images and using the collision data to test a few things.
I've improved a few things and tested a few things. UHM
here's a list


TODO:


Note: THIS ISNT ALL OF IT
Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on January 03, 2012, 02:57:16 PM
OK so I'm going to end up updating this to be semi multiplayer.
I'm considering changing the engine around and adding a forces property , or a set of forces property to in game objects.
So that, when objects collide I can check force against xyz.

Not sure yet. I'll be testing local multiplayer first, maybe. .. :/ one person can play as diddy, the other as dixie, that would be interesting :O

Ok I decided instead of fixing the camera I'm going to add the following items to the dkc2 engine today.
Bananas
Blast barrels
Hooks for the player to hang off of and jump using from hook to hook.
also adding in today
The ability for dixie to helicopter the way she can in the original.
This should make for a more interesting test level.
Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on January 04, 2012, 09:10:43 AM
Update:

Checklist :

Bananas: Added
Better Gravity: Added (downward force or momentum integer only. )
Banana frames: added
Bananas are collectible: added
Dixie Spin attack. Dixie helicopter downwards (reduces current fallspeed by half, makes maximum fallspeed 2 instead of 4): Added

TODO:

create counter for bananas
Bananas are only randomized. Must change to user based placement.
Remove limit of only 300 bananas per level.
Import text for banana counter and have it display.
Add animations for balloons increase.
Add HUD : Balloons, Bananas, Coins.
Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on January 04, 2012, 11:39:21 AM
(http://i43.tinypic.com/2jcwkkw.png)




Current Code:

Posted for learning and observation purposes.
[pbcode]
; PROJECT : Castle Crush
; AUTHOR  : NA
; CREATED : 12/27/2011
; EDITED  : 1/4/2012
; ---------------------------------------------------------------------
castle=loadnewfximage("castlecrush.png")
imagemaskcolour castle, rgb(255, 0, 255) ;purpleish?
;imagemaskcolour castle, rgb(255, 255, 255) ;white
mode=loadnewfximage("mode.png")
HEIGHT=getimageheight(castle)
WIDTH=getimagewidth(castle)
save=loadnewfximage("save.png")
playmode=loadnewfximage("Playmode.png")
grid=false
backdrop=loadnewfximage("castle.png")
levelname$="castle crush"
wall=loadnewfximage("wall.png")
wallx=0
wally=12256-200
bananatimer=timer()+30
spinframe=1
spinframetimer=timer()+30




dim dixieright(18)
dim dixieleft(18)
for temp=1 to 18
   dixieright(temp)=loadnewfximage("Sprites/dixieframe"+str$(temp)+".bmp")
   imagemaskcolour dixieright(temp), rgb(255,255, 255)
   dixieleft(temp)=newfximage(55, 45)
   copyimage dixieright(temp), dixieleft(temp)
   mirrorimage dixieleft(temp), 1, 0
next temp


dim dixiejumpright(4)
dim dixiejumpleft(4)

for temp=1 to 4
   dixiejumpright(temp)=loadnewfximage("Sprites/dixiejump"+str$(temp)+".bmp")
   imagemaskcolour dixiejumpright(temp), rgb(255, 255, 255)
   dixiejumpleft(temp)=newfximage(55, 74)
   copyimage dixiejumpright(temp), dixiejumpleft(temp)
   mirrorimage dixiejumpleft(temp), 1, 0
   imagemaskcolour dixiejumpleft(temp), rgb(255, 255, 255)
next temp

;load and flip dixie's spinning animations for hovering helicoptering
   
   
   dim dixiespinright(10)
   dim dixiespinleft(10)
   for temp=1 to 10
      dixiespinright(temp)=loadnewfximage("Sprites/dixiespin"+str$(temp)+".bmp")
      dixiespinleft(temp)=newfximage(getimagewidth(dixiespinright(temp)), getimageheight(dixiespinright(temp)) )
      copyimage dixiespinright(temp), dixiespinleft(temp)
      mirrorimage dixiespinleft(temp), 1, 0
      imagemaskcolour dixiespinright(temp), rgb(255, 255, 255)
      imagemaskcolour dixiespinleft(temp), rgb(255, 255, 255)
   next temp
      
   
dim bananaframes(8)
for temp=1 to 8
   bananaframes(temp)=loadnewfximage("Sprites/bananaframe"+str$(temp)+".png")
   imagemaskcolour bananaframes(temp), rgb(255, 255, 255)
next temp

type banana
   x
   y
   frame
   collected
endtype

dim bananas(300) as banana
for temp=1 to 300
   bananas(temp).x=rndrange(0, 512)
   bananas(temp).y=rndrange(0, 12256)
   bananas(temp).frame=rndrange(1, 8)
   bananas(temp).collected=false
   next temp
      

dixieaction=1
jumpframe=1

   

SCROLLX=0
SCROLLY=11776
MAPWIDTH=roundup(WIDTH/16)
MAPHEIGHT=roundup(HEIGHT/16)
dim map(MAPWIDTH, MAPHEIGHT)
spritewidth=35
spriteheight=25
dixieframe=1
frametimer=timer()+30
maxfallspeed=4
falltimer=timer()+150 ;.5 miliseconds for falling increase

type solid_tile
   x1
   y1
   x2
   y2
endtype
   

dim solids(MAPWIDTH, MAPHEIGHT) as solid_tile
read=false
if fileexist("C:\\castlemap.txt") then read=true

IF READ=TRUE
readfile "C:\\castlemap.txt", 1
rendertoimage castle
for tempx=1 to MAPWIDTH
   for tempy=1 to MAPHEIGHT
      map(tempx, tempy)=readint(1)
      solids(tempx, tempy).x1=readint(1)
      solids(tempx, tempy).y1=readint(1)
      solids(tempx, tempy).x2=readint(1)
      solids(tempx, tempy).y2=readint(1)
      x1=solids(tempx, tempy).x1
      y1=solids(tempx, tempy).y1
      x2=solids(tempx, tempy).x2
      y2=solids(tempx, tempy).y2
      ink rgb(0, 0, 255)
      box x1, y1, x2, y2, 0
   next tempy
next tempx
closefile 1

   ENDIF
      

myimage=newfximage(640, 480)
imagemaskcolour myimage, rgb(255, 0, 255) ;purple ish?
;imagemaskcolour myimage, rgb(255, 255, 255);  white
MODE$="View"


rendertoimage castle

if grid=true
for tempx=1 to WIDTH/16
   for tempy=1 to HEIGHT/16
      ink rgb(255,255, 255)
      box (tempx-1)*16, (tempy-1)*16, tempx*16, tempy*16, 0
   next tempy
next tempx   
endif
   
      
wallspeed=25
charx=400
chary=12128
falling=false
walltimer=timer()+wallspeed
spunalready=false
spinning=false

do
   
   
   

         
                        
   
   if enterkey()
      chary=1
      scrolly=0
   endif
      
   
   if falling=true
      if timer()>falltimer
         fallspeed=fallspeed+1
         falltimer=timer()+150
         if fallspeed>maxfallspeed then fallspeed=maxfallspeed
      endif
   endif
         
         
   
   ;for temp=1 to 300
      ;pushbananaframe(temp)
      ;next temp
   
   ;if timer()>walltimer
      ;walltimer=timer()+wallspeed
   
   ;if falling=true
   ;if chary=>wally-spriteheight-1
   ;   chary=wally-spriteheight-1
      ;landed=true
   ;   falling=false
      ;onwall=true
;   else
   ;   onwall=false   
;endif
;endif   


   
      
      if jump=false
         if falling=false
            if onwall=true
               ;chary=chary-1
            endif
         endif
      endif
      
   ;   wally=wally-1
   ;scrolly=scrolly-1      
      
      
   
   
   if mode$="playmode"
   if onwall=true
      
            ;pan camera down slowly
               if scrolly<wally-400
                  scrolly=scrolly+2
                  scrollimage backdrop, 0, -1
               else   
      scrolly=wally-400
            endif
      if scrolly>11776 then scrolly=11776
   endif   
   endif   
      

   


         

;draw map


;render to the map image
rendertoscreen


         
rendertoimage castle

x=mousex()
y=mousey()

if SCROLLX=>16
   amountx=roundup(SCROLLX/16)
   else amountx=1
endif
   ;top side same thing as above
if SCROLLY=>16
   amounty=roundup(SCROLLY/16)
else
   amounty=1
endif







moveright=true
moveleft=true

      


for tempx=amountx to 32  ;disable x scroll for this entirely for the right side
   for tempy=amounty to 30+amounty
      
      x=(tempx-1)*16
      y=(tempy-1)*16
      
      xdraw=x-SCROLLX
      ydraw=y-SCROLLY
      ink rgb(0, 255, 0)
      ;box x, y, x+16, y+16, 0
            
            ;check solid tiles below character
            
            
            
            ;check player on tile
                  
                  if map(tempx, tempy)=1       ;if the tile is solid, check against player collision         
                     
                     
               checkingx1=solids(tempx, tempy).x1
               checkingy1=solids(tempx, tempy).y1
               checkingx2=solids(tempx, tempy).x2
               checkingy2=solids(tempx, tempy).y2
               
               
                           
                           playerx1=charx
                           playery1=chary
                           playerx2=charx+spritewidth
                           playery2=chary+spriteheight
                           
                           if spinning=true
                              checkspeed=fallspeed/2
                              else
                                 checkspeed=fallspeed
                           endif
                        
                                       
                           
                           if playerx2>checkingx1         ;the players x coordinates align
                           if playerx1<checkingx2                  
                                    if playery1<checkingy1 ;the players top edge is not past the top of the platform
                                 if playery2>checkingy1-checkspeed ;the players bottom edge IS past the top of the platform-1 pixel
                                       landed=true
                                       fallspeed=1
                                       spunalready=false
                                       spinning=false
                                       spinframe=1
                                       falling=false
                                    endif
                                 endif
                           endif
                        endif
                              
                                       
                                 
                           
                              ;check for left and right sides
                  ;check left collision (Player is here --> ||Colliding with LEFT wall of object)

                                             
                     if playerx2>checkingx1-1
                        if playerx2<checkingx1+1
                           if playery2>checkingy1
                              if playery1<checkingy2
                                 moveright=false
                              else
                                 moveright=true
                              endif
                           endif
                        endif
                     endif
                                    
                                    ;check right collision
                     if playerx1>checkingx2-1
                        if playerx1<checkingx2+1
                           if playery2>checkingy1
                              if playery1<checkingy2
                                 moveleft=false
                              else
                                 moveleft=true
                              endif
                           endif
                        endif
                     endif
                                    
                     
                           
                           
                           
                           
                  endif
                  
                  
                     
                     
                     
                  
                              
                                                                        
            
                              
            
            
            if mode$="Collision"         ;only place tiles if mode is collision
            
            
            
            
            
            if mouseinbox(xdraw, ydraw, xdraw+16, ydraw+16)
               if rightmousebutton()
                  charx=x
                  chary=y
               endif
               endif   
               
            
            
      if leftmousebutton()
         if mouseinbox(xdraw, ydraw,xdraw+16, ydraw+16)
            box x, y, x+16, y+16, 0
            map(tempx, tempy)=1
            solids(tempx, tempy).x1=x
            solids(tempx, tempy).y1=y
            solids(tempx, tempy).x2=x+16
            solids(tempx, tempy).y2=y+16
         endif
   endif
            endif   
            
      
      
   next tempy
next tempx

               if falling=true                     ; set the spinning flag if falling and upkey is pressed
      if spinning=false
         if spunalready=false
            if landed=false
            if spacekey()
               spinning=true
               spunalready=true
            endif
         endif
      endif
endif
endif
   
   
                           ; if upkey is held player is spinning
   if falling=true
      if spinning=true
         if spunalready=true
            if landed=false
            if spacekey()   
            spinning=true
         else
            spinning=false
         endif
      endif
endif
endif   
endif



   if spinning=true
      if timer()>spinframetimer
         spinframetimer=timer()+30
         spinframe=spinframe+1
         if spinframe>10 then spinframe=1
         endif
      endif            
                        
                        
                        
                        

                  if mode$="playmode"
                     if jump=false
               if landed=false
            
            ;handle character falling
                  if falling=true
                     
                     if spinning=true
                        spinfallspeed=fallspeed/2
                     chary=chary+spinfallspeed
                  else
                     chary=chary+fallspeed   
                  endif
                     
                        
                     if chary=>480/2         ;sloppy attempt at keeping the player centered on camera
                        
                     if falling=true
                        if spinning=false
                        scrolly=scrolly+fallspeed
                     else
                        scrolly=scrolly+spinfallspeed
                     endif
                     endif
                           
                        
                        scrollimage backdrop, 0, -fallspeed/2
                     endif
                        
                  endif
                  
                     
               
                     
               
               
               
               endif ;only execute character falling code if landed is false.
            endif         ;end the code for jumping
                  
                  
                     endif
                        
                     
                     
                              
                     
            ink rgb(0, 0, 255); blue

   
   ink rgb(255, 255, 255)
      


      ;for temp=1 to roundup(640/163)
      ;drawimage wall, (temp-1)*163, wally, 0
         ;next temp
         
         
      
         
      getimage myimage, 0+scrollx, 0+scrolly, 640+scrollx , 480+scrolly
      
      ;make sure it doesn't scroll past the left or right side too far
      if scrollx<=0 then scrollx=0
      ;if scrollx+640=>WIDTH then scrollx=WIDTH-640

      ;make sure it doesn't scroll past the top or bottom side too far
      if scrolly<=0 then scrolly=0
      if scrolly+480=>HEIGHT then scrolly=HEIGHT-480
   
         
         
         
      
      rendertoscreen
      ;box charx, chary, charx+16, chary+16, 0
      charx1=charx
      chary1=chary
      charx2=charx+spritewidth
      chary2=chary+spriteheight
      charx1=charx1-scrollx
      chary1=chary1-scrolly
      charx2=charx2-scrollx
      chary2=chary2-scrolly
      
      
      
      
      for tempx=1 to 2
         for tempy=1 to 2
            drawimage backdrop, (tempx-1)*320, (tempy-1)*256, 0
      next tempy
      next tempx   
         
            
      
      drawimage myimage, 0, 0, 1
      drawimage mode, 640, 100, 0
      drawimage save, 640, 200, 0
      drawimage playmode, 640, 300, 0
      
      if timer()>bananatimer
         bananatimer=timer()+30
         pushframes=true
      endif
         
      
      for temp=1 to 300
         number=temp
         frame=bananas(temp).frame
         x=bananas(temp).x
         y=bananas(temp).y
         collected=bananas(temp).collected
         if collected=false
         drawimage bananaframes(frame), x-scrollx, y-scrolly, 1
         if pushframes=true
         pushbananaframe(number)
         endif
         endif
         
         
         if charx+spritewidth=>x
            if chary+spriteheight=>y
               if charx<x+16
                  if chary<y+16
                     bananas(temp).collected=true
                  endif
               endif
            endif
         endif
                     
         
         next temp
      
      ink rgb(0, 0, 255)      ;blue character
      ;box charx1, chary1, charx2, chary2, 1
      box charx1, chary1, charx2, chary2, 0
      
      if dixieaction=1
      if landed=true
      drawimage dixieright(dixieframe), charx1, chary1-spriteheight/2, 1
      else
            if jump=true   
      drawimage dixiejumpright(jumpframe), charx1, chary1-36, 1
      else
      if spinning=false   
      drawimage dixiejumpright(4), charx1, chary1-36, 1
      else
      
      drawimage dixiespinright(spinframe), charx1, chary1-spriteheight/2, 1
      
      endif   
      endif
      endif
      endif
      
      if dixieaction=2
      if landed=true
      drawimage dixieleft(dixieframe), charx1-16, chary1-spriteheight/2, 1
      else
            if jump=true
      drawimage dixiejumpleft(jumpframe), charx1-16, chary1-36, 1   
      else
      if spinning=false   
      drawimage dixiejumpleft(4), charx1-16, chary1-36, 1
      else
      
         drawimage dixiespinleft(spinframe), charx1, chary1-spriteheight/2, 1
      
      endif   
      endif
      endif
      endif
               
            
      ink rgb(0, 255, 255) ;white
      
      
      
      
text 200, 500, "SCROLLY " +str$(Scrolly)+" --ROUNDED to tile index: "+str$(amounty)
text 200, 520, "SCROLLX " +str$(Scrollx)+" --ROUNDED to tile index: "+str$(amountx)
text 200, 540, "This is the result of WIDTH <> scroll X"+str$(WIDTH-(640+scrollx))+"and"+str$(WIDTH)
text 200, 560, "Playerx : "+str$(charx)+" Playery : "+str$(chary)

if mouseinbox(640, 100,  640+128, 164)
   if leftmousebutton()
      mode$="Collision"
   endif
endif

if mouseinbox(640, 300, 640+(128*3), 364)
   if leftmousebutton()
      mode$="playmode"
      falling=true
   endif
endif
      

   if mouseinbox(640, 200, 640+(128*2), 264)
      if leftmousebutton()
            
            writefile "C:/castlemap.txt", 1
            
            for tempx=1 to Mapwidth
               for tempy=1 to mapheight
                  writeint 1, map(tempx, tempy)
                  writeint 1, solids(tempx, tempy).x1
                  writeint 1, solids(tempx, tempy).y1
                  writeint 1, solids(tempx, tempy).x2
                  writeint 1, solids(tempx, tempy).y2
               next tempy
            next tempx
            closefile 1
                  
         
      endif
      endif   

      

;scrolling input




if leftkey()
   ;scrollx=scrollx-8
   dixieaction=2
   if timer()>frametimer
   dixieframe=dixieframe+1
   
   if dixieframe>16 then dixieframe=1
   frametimer=timer()+30
endif

if moveleft=true   
   
   charx=charx-1

endif

endif



      
if rightkey()
   ;scrollx=scrollx+8
   dixieaction=1
   if timer()>frametimer
   dixieframe=dixieframe+1
   
   if dixieframe>16 then dixieframe=1
   frametimer=timer()+30
   endif
   
   if moveright=true
   
   charx=charx+1


endif

   

endif

      if mode$<>"playmode"
      
      if downkey()
         scrolly=scrolly+8
      endif
   
      if upkey()
      scrolly=scrolly-8
      endif

endif
   
         
         
               if mode$="playmode"
                  
                  
            if jump=false
            if upkey()
               if landed=true
            jump=true
            upforce=65
            jumpframetimer=timer()+600
      endif
endif
endif
   
      
            
         
         
         
            if jump=true
               
               
               chary=chary-2
               upforce=upforce-2
               scrolly=scrolly-2
               scrollimage backdrop, 0, 1
               if timer()>jumpframetimer
                  jumpframe=jumpframe+1
                  if jumpframe>4 then jumpframe=4
                  jumpframetimer=timer()+600
      endif
   endif   
         
         if jump=true
         if upforce=<0
            jump=false
            falling=true
            landed=false
            upforce=0
            endif
            endif   
            
            
            
            endif
               
            

      falling=true
      landed=false
      ;moveright=true
      pushframes=false
sync
cls rgb(0,0,0)
loop




function draw_blank_tiles()
for tempx=amountx to 20+amountx+1
   for tempy=amounty to 15+amounty+1
      
      x=(tempx-1)*32
      y=(tempy-1)*32
      
      xdraw=x-SCROLLX
      ydraw=y-SCROLLY

   
         
      
      ;tilenum=map(tempx, tempy)
      ;print "Tilenum is" +str$(tilenum)
      ;print "Press key to show image"
      ;waitkey
      ;waitnokey
      ;sync
         
         if tilenum=<0 then tilenum=1
         if tilenum=>101 then tilenum=100
         
      ;drawimage tiles(tilenum), xdraw, ydraw, 0
      
next tempy

      
         
               
               
   next tempx   
      rendertoscreen
drawimage timage, 0, 0, 0
endfunction

function pushbananaframe(number)
   
   bananas(number).frame=bananas(number).frame+1
   if bananas(number).frame>8 then bananas(number).frame=1
   
endfunction


[/pbcode]

I'll post the actual demo now it's far enough along and I'm happy with it. Note: You'll need to paste in your own platforms using the editor feature.
Download link attached below!!


http://www.megaupload.com/?d=K3N1POX4 (http://www.megaupload.com/?d=K3N1POX4)

PLEASE reply to this post and leave your comments, questions etc. if you download the file, Please post! I want to know what you think :D :D

Instructions:

Play mode:
Up down left right (moves character)
UP: Jump
Space: While jumping, or falling: Spin/helicopter
Release space while helicoptering: Fall faster.

Collision mode:
up down left right (moves character)
UP: jump
Space : While jumping or falling: Spin/helicopter
note: You do not fall in collision mode
Mouse buttons: Left mouse: Place solid tile. For collision. Right mouse: move character

Enter key: Mode: ANY: reset character and camera to top of map/level

View mode: Nothing. But scroll. Click collision mode, or play mode, to play.

Note: You will have to place your own tiles through the map and then click save map if you want to reload it next time.

Other notes: Banans can not be edited in this version. But you CAN collect them. TRY TO GET THEM ALL :D
There is no counter for the bananas yet.
The jump height is exactly four collidable tiles tall. You can not jump any higher. It may have changed due to gravity physics being changed.
The rest should be straightforeward.
Note: In order to actually play, you have to click play mode in the menu.

If you begin falling off the very edge of the map at the bottom just press enter.
Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on January 04, 2012, 02:16:58 PM
I updated the camera with this code :


I got these values by taking my drawing surface size 640, 480.
Divide both by two.
Add the 640 to the scrollx so were looking at it's right edge, for the left side and how far away from the player it is from the camera, do the same to the scrolly.
Then leave the other values as they are because this time if the player is too far ahead of the camera's X1 coordinates and Y1 coordinates we move the camera foreward to catch up to the player. the other first two move the camera backwards
Since the drawing routine copies using scrollx and scrolly this works as a basic camera following AI. It's a little shaky needs some work. :D
[pbcode]
   
            if scrollx+640-charx>320      ;left side
               scrollx=scrollx-3
            endif
            
            if scrolly+480-chary>240   ;top   side
               scrolly=scrolly-3
            endif
         
                  
            if chary-scrolly>240   ;right side
               scrolly=scrolly+3
            endif
               
            if charx-scrollx>320   ;left side.
               scrollx=scrollx+3
            endif

[/pbcode]

I also tried to put in 8000 bananas into my game loop.
The framepush function I have must be the thing lagging it out.
I have about 3 for temp loops already in my code, and they're all unique and all required.
Everything is as optimized as I can get it including a check which makes sure that it only asks against tiles that actually exist (gridlocked) for collision checks.
Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: monkeybot on January 05, 2012, 03:18:13 PM
seems good so far.
Keep it up!
Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on January 06, 2012, 01:50:13 PM
Okay another update.
A bunch of stuff got changed and is still in the works.
I'm working on the camera right now. Fixed that.
I also fixed a few other things, and at the moment including the helicopter is more acurate to the original game mechanics.
You weren't able to helicopter at any point in a jump before, but now you can.
AND  , your fall speed gets reset to 1 when you do.
There's an update in the loop which checks the helicopter state, and updates the oldfallspeed as fallspeed.
fallspeed and the value which controls how fast you fall as your helicoptering are different, but fallspeed controls both the helicopter fallspeed and your original fallspeed.

Because helicopter fallspeed is derived from the fallspeed value then setting oldfallspeed=fallspeed in the update for the helicopter loop, as fallspeed is increasing each timer cycle it results we end up with the result of helicopterfallspeed=fallspeed/2. Uhm, and at the end of it if the helicopter loop is false, then the helicoptering ends and we end up with fallspeed=oldfallspeed, which basically appears to make you fall faster than you were while helicoptering, which is basically what happens anyhow.. but it makes sense to stop the fallspeed and reduce back to 1, once helicoptering starts. A flaw in the old version, which I wasn't doing or accounting for.

Physics gets interesting even basic physics.

Well, here's the new code. And uh, an upload. Oh a note: The level is now both horizontal and vertical and collision is account for in all directions. Camera centering is a bit buggy while placing tiles right click to drag camera around. Or use arrow keys. Next update will be made so camera only follows player when in play mode.
The jump height was also improved. Levels are larger.

http://www.megaupload.com/?d=401AGDX6 (http://www.megaupload.com/?d=401AGDX6)

Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: kevin on January 06, 2012, 08:28:42 PM

To be honest, i'm not really sure what the demo is meant to do, as all i see is a scrolling backdrop when in play mode (pictured bellow)..

After looking at the code, it's referencing at least one file that's not included in the archive.

Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: kevin on January 07, 2012, 05:28:32 AM

  Had a look at the demo again, didn't initially realize that you're using a pre-rendered picture for the map ? - That picture is eating up some 25 meg of memory at run time and bloating the archive size.

  So attached is the level picture converted into a tile + block map.  At a block size of 32*32 there's only 91 unique tiles, weighing in around 400K.     
Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on January 20, 2012, 12:27:13 AM
VIDEO DEMONSTRATING GAME ENGINE AS OF SO FAR


http://youtu.be/Q-oF2_8eDL4
Platforming Stuff, and collect bananas



http://youtu.be/AxQOaBWi1wU

Pick up and put down barrels with some glitches (Just haven't gotten to them yet they're easy to fix)
Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on January 20, 2012, 03:29:17 AM
And would you believe after about 3 or 4 hours of coding and preparing more graphics by focusing the sprites properly in seperate frame images, I'm not even done getting all the sprites for dixie yet?
I still have to prepare the ones of her walking while carrying a barrel, running while carrying a barrel. Jumping while carrying a barrel (it's 2-3 frames animated). And I still have to get sprites of her throwing the barrel up and foreward.
And sprites of the barrels rolling/smashing.

The reason it's running so slowly in the video is because my recording software sucks.
I'm using procaster from livestream and it sucks memory like crazy!
Anyone got anything better? >.<
Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: kevin on January 20, 2012, 10:54:16 AM

I use  [plink]PBAVI (http://www.underwaredesign.com/forums/index.php?topic=3342.0)[/plink], Cam Studio + Virtual Dub for clipping and compressing. 



 
Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: buggage on January 20, 2012, 05:46:22 PM
QuoteAnd would you believe after about 3 or 4 hours of coding and preparing more graphics by focusing the sprites properly in seperate frame images, I'm not even done getting all the sprites for dixie yet?

http://www.mariouniverse.com/sprites/snes/dkc2

http://sdb.drshnaps.com/display.php?object=7654

Will these help?

Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on January 20, 2012, 06:28:12 PM
UPDATE

I fixed a glitch where barrels were falling off of platforms because the checking system I had to see if they landed was ONLY within visible screen boundaries.
Believe it or not this wasn't a result of putting the collision code in the drawing routine but it was however a result of trying to use the same collision code that works for the player in this.
now I need to set up an input configuration screen because the controls are getting a bit er... for editing. Yeah..

So far you can check the index of a barrel object, and view it.
I'm going to put an official "object" viewer into the engine next so that it displays different objects you have selected and give the game engine a better input handling system.

Where, the input is collected at the start of the loop, and then stored in memory.

Then, a few crucial input checking steps will take place before the engine decides which input is the most valid.

Fix a few graphical glitches and finish polishing up dixie's grab sprites. WOO. Progress.
Phew.

This is the first and only platforming engine I've seen say other than terraria where an object can fall an extremely long distance, and still be accounted for off screen. Granted I play alot of super nintendo games, and in most of those games objects that are on screen don't end up staying in memory very long if you go too far.

I also figured out how to create a respawn system for enemies, so that when a player goes offscreen even if the enemy has moved away from it's original path or starting point it gets placed back.
We're going to have some fun with this in the next few days if moving doesn't take up all my time! :P BY WE I MEAN ME and anyone else who tries this out.
Once I get some of the other game mechanics worked out I'll fix up the banana system and life system, and start adding in baddies. Such as bees,
Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on January 20, 2012, 11:03:45 PM
Quote from: buggage on January 20, 2012, 05:46:22 PM
QuoteAnd would you believe after about 3 or 4 hours of coding and preparing more graphics by focusing the sprites properly in seperate frame images, I'm not even done getting all the sprites for dixie yet?

http://www.mariouniverse.com/sprites/snes/dkc2

http://sdb.drshnaps.com/display.php?object=7654

Will these help?



Yes it would help thank you but I've already seen those two sites.
More less, the work involves taking those sprite sheets and splitting each image into a frame and then figuring out the offsets for that frame and animating it, or editing the sprite within the frame so it's centered right for each frame in the anim.

Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on January 20, 2012, 11:07:37 PM
Here's an update.
I got the tiles and some backdrops from the brambles levels in dkc2.
Meaning, 2d paralex layered scrolling is being integrated.
I also fixed dixie's walk/run speed.
I fixed the bug where barrels weren't landing on platforms that were off screen and a bug while in collision mode where if you placed a platform below a barrel that was already on a platform the barrel would fall through the platform it was on in favor of the next one down. Mind you (This bug could be a feature in another game sometime down the road )
Dixie can now pick up barrels facing both ways but it's a bit buggy same with putting down barrels.

Here's a screenshot showing her proudly holding up her first barrel in this engine and in the brambles scene with bananas, No brambles tiles integrated yet but tonight I'll either put tiles into the game engine (maybe :/) or enemies. Who knows.. who knows indeed ^^; we'll see.
Keep in mind, alot of the code for dixie's sprite is very sketchy right now since it's still WIP.
I'm getting closer to perfecting a few things though about the way she moves and making it closer to the original.

Here's a screenshot!!!

Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on January 21, 2012, 03:12:22 AM
And more progress.

I got some kind of a tile system integrated.

It's going good.

Tiling with the brambles tileset isn't exactly the easiest though. I think I'm missing a few.
Screenshot
Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on January 22, 2012, 02:39:02 AM
I've added tiles to the game engine, and now I have a video showing them off. And a few other things about the game engine as well.
Enjoy.

Who would have thought playbasic was capable of this?
And this is only the start.

http://youtu.be/mTRRzKzNNg8

Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on January 22, 2012, 08:45:30 AM
and now there's been an update.
I added bees, the bugs that walk around, beatles.
I added a better tile editing system.
A second screen for picking objects. (Woo)

You can now select one of four barrels.
No screenshot because my eyes burn like crazy I've been at this forever. I'm infact making this post then sleeping. Don't worry I do get sleep.
Anyhow..

Basically I added a ton of new cool stuff and here's a download link:

http://www.filefactory.com/file/c2b1507/n/Alpha_0.01.rar

The controls are this

Collision mode:
Left click: Places solid green tiles
Right click: moves dixie to your location
Arrow keys (Scroll the map)

Tile editing mode:
Press the / key on your numblock pad and it lets you pick and place tiles.
Use the up or down arrow keys on your numpad, to move the tiles themselves around (TO scroll within the tile selection area)
Left click on the level: Places a tile
Left click on the tile selection: Selects a tile
Pretty straightforeward.

Play mode:
Spacekey is helicopter spin (hold)
Left and right keys (move left and right)
Upkey: Jump
Space key while facing a barrel : pick up the barrel
Down key while holding the space key: put the barrel down
Jump,  hold foreward and space: helicopter spin left or right, say across large gaps? ;)

How to access a second menu:

Left Shift key or right Shift key will change between viewing the tile selection menu or the barrel selection menu.
Controls for selecting a barrel.
Left click on a barrel of the type of your choice.
Then, left click, anywhere in the level editing area. (The area where you see all the brambles and the sky moving)
When your satisfied with where the barrel is, right click. Anywhere, doesn't matter.
The barrel will get de selected and voila.

To test it, make sure you're in collision mode and right click above the barrel. This will move dixie to it. If you fall down, Press enter to get to the top of the level OR just use the arrow keys (WHILE IN COLLISION MODE REMEMBER) and the right mouse button to bring dixie where you want her.
Then, let her hang in mid air in collision mode above your barrel or beside it, and then click on playmode.

Although it is to be noted the barrels will BLAST you and move your view across the screen even if you aren't in collision mode, so keep dixie away from those blast barrels until you're ready! Alright guys... I HOPE that you will try this out. I'm working really hard on this.
And it's not even close to being complete yet. It kind of feels unreal that I'm pulling this off hehe.



NOTE: Right when the editor starts your in view mode YOU Have to click on collision mode to activate it.
See all those barrels and bugs falling? I would quickly place platforms below them by using the arrow keys to scroll past them and placing solid tiles below them in a row.
The save feature is bugged right now. Sorry!

Oh yes. I added bees.
Don't worry they won't hurt you.

Cya for now.
Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on January 23, 2012, 01:10:36 AM
Current Code:

[pbcode]



; PROJECT : Castle Crush
; AUTHOR  : NA
; CREATED : 12/27/2011
; EDITED  : 1/23/2012
; ---------------------------------------------------------------------
openscreen 1024, 768, 32, 1
;castle=loadnewfximage("castlecrush.png")
openscreen 1024, 768, 32, 1
;castle=newfximage(12000, 500*16)
;rendertoimage castle
cls rgb(255, 255, 255)
;imagemaskcolour castle, rgb(255, 0, 255) ;purpleish?
;imagemaskcolour castle, rgb(255, 255, 255) ;white
mode=loadnewfximage("mode.png")
HEIGHT=500*16
WIDTH=12000
save=loadnewfximage("save.png")
playmode=loadnewfximage("Playmode.png")
grid=false
backdrop=loadnewfximage("Sprites/Bramble_backdrop.bmp")
imagemaskcolour backdrop, rgb(255, 255, 255)
sky=loadnewfximage("Sprites/Bramble_sky.bmp")
levelname$="castle crush"
wallx=0
wally=0
bananatimer=timer()+30
spinframe=1
spinframetimer=timer()+30
maxhelicopterfall=4
barreli=loadnewfximage("Sprites/barrel.bmp")
imagemaskcolour barreli, rgb(255, 255, 255)
dixieholdingbarrel=false
barrelwidth=30
barrelheight=39
pickingup=false
puttingdown=false
barrelfalltimer=timer()+30
fallspeed=1
menu=1 ;menu means current view of objects/tiles/sprites


inbarrel=false



tiles=loadnewfximage("Sprites/Tiles Editing.bmp")
dim tiles(598)

tile=1
rendertoimage tiles
for tempx=1 to 23
   for tempy=1 to 26
      x1=(tempx-1)*32
      y1=(tempy-1)*32
      x2=tempx*32
      y2=tempy*32
      ;x1=x1+tempx ;account for white space    
      ;y1=y1+tempy   ;account for white space
      ;x2=x2+tempx   ;account for white space
      ;y2=y2+tempy   ;account for white space
      tiles(tile)=newfximage(32, 32)
      
      getimage  tiles(tile), x1, y1, x2, y2
      imagemaskcolour tiles(tile), rgb(255, 255, 255)
      tile=tile+1
      ;if tile>598 then tile=598
      ;sync
   next tempy
   next tempx   
      
rendertoscreen
deleteimage tiles



dim dixieright(18)
dim dixieleft(18)
for temp=1 to 18
   dixieright(temp)=loadnewfximage("Sprites/dixieframe"+str$(temp)+".bmp")
   imagemaskcolour dixieright(temp), rgb(255,255, 255)
   dixieleft(temp)=newfximage(55, 45)
   copyimage dixieright(temp), dixieleft(temp)
   mirrorimage dixieleft(temp), 1, 0
next temp


dim dixiejumpright(4)
dim dixiejumpleft(4)

for temp=1 to 4
   dixiejumpright(temp)=loadnewfximage("Sprites/dixiejump"+str$(temp)+".bmp")
   imagemaskcolour dixiejumpright(temp), rgb(255, 255, 255)
   dixiejumpleft(temp)=newfximage(55, 74)
   copyimage dixiejumpright(temp), dixiejumpleft(temp)
   mirrorimage dixiejumpleft(temp), 1, 0
   imagemaskcolour dixiejumpleft(temp), rgb(255, 255, 255)
next temp

;load and flip dixie's spinning animations for hovering helicoptering
   
   
   dim dixiespinright(10)
   dim dixiespinleft(10)
   for temp=1 to 10
      dixiespinright(temp)=loadnewfximage("Sprites/dixiespin"+str$(temp)+".bmp")
      dixiespinleft(temp)=newfximage(getimagewidth(dixiespinright(temp)), getimageheight(dixiespinright(temp)) )
      copyimage dixiespinright(temp), dixiespinleft(temp)
      mirrorimage dixiespinleft(temp), 1, 0
      imagemaskcolour dixiespinright(temp), rgb(255, 255, 255)
      imagemaskcolour dixiespinleft(temp), rgb(255, 255, 255)
   next temp
      
      
      dim dixiepickupbarrelright(14)
      dim dixiepickupbarrelleft(14)

for temp=1 to 14
   dixiepickupbarrelright(temp)=loadnewfximage("Sprites/dixiepickupbarrel"+str$(temp)+".bmp")
   dixiepickupbarrelleft(temp)=newfximage(getimagewidth(dixiepickupbarrelright(temp)), getimageheight(dixiepickupbarrelright(temp)) )
   copyimage dixiepickupbarrelright(temp), dixiepickupbarrelleft(temp)
   mirrorimage dixiepickupbarrelleft(temp), 1, 0
   imagemaskcolour dixiepickupbarrelleft(temp), rgb(255, 255, 255)
   imagemaskcolour dixiepickupbarrelright(temp), rgb(255, 255, 255)
next temp

         
         
         dim barrel_(4)
         barrel_(1)=loadnewfximage("Sprites/Barrelup.bmp")
         barrel_(2)=loadnewfximage("Sprites/Barreldown.bmp")
         barrel_(3)=loadnewfximage("Sprites/Barrelleft.bmp")
         barrel_(4)=loadnewfximage("Sprites/Barrelright.bmp")
         for temp=1 to 4
            imagemaskcolour barrel_(temp), rgb(255, 255, 255)
         next temp
            
         
         
                     
            
            ;load zingers graphics
      
      dim zingerfacesleft(3)
      dim zingerfacesright(3)
         for temp=1 to 3
         zingerfacesleft(temp)=loadnewfximage("Sprites/zingerframe"+str$(temp)+".bmp")
         zingerfacesright(temp)=newfximage(getimagewidth(zingerfacesleft(temp)), getimageheight(zingerfacesleft(temp)) )
         copyimage zingerfacesleft(temp), zingerfacesright(temp)
         mirrorimage zingerfacesright(temp), 1, 0
         imagemaskcolour zingerfacesleft(temp), rgb(255, 255, 255)
         imagemaskcolour zingerfacesright(temp), rgb(255, 255, 255)
      next temp
      
      dim beatlefacesleft(8)
      dim beatlefacesright(8)
      
      for temp=1 to 8
         beatlefacesleft(temp)=loadnewfximage("Sprites/Bugframe"+str$(temp)+".bmp")
         beatlefacesright(temp)=newfximage(getimagewidth(beatlefacesleft(temp)), getimageheight(beatlefacesleft(temp)) )
         copyimage beatlefacesleft(temp), beatlefacesright(temp)
         mirrorimage beatlefacesright(temp), 1, 0
         imagemaskcolour beatlefacesleft(temp), rgb(255, 255, 255)
         imagemaskcolour beatlefacesright(temp), rgb(255, 255, 255)
         next temp
               
   
dim bananaframes(8)
for temp=1 to 8
   bananaframes(temp)=loadnewfximage("Sprites/bananaframe"+str$(temp)+".png")
   imagemaskcolour bananaframes(temp), rgb(255, 255, 255)
next temp


type banana
   x
   y
   frame
   collected
endtype

dim bananas(50) as banana
for temp=1 to 50
   bananas(temp).x=rndrange(0, WIDTH/5)
   bananas(temp).y=rndrange(0, HEIGHT/5)
   bananas(temp).frame=rndrange(1, 8)
   bananas(temp).collected=false
   next temp
      
      
      
   type zinger
      x1
      y1
      x2
      y2
      frame
      frametimer
      facing
      directionleft
endtype

   type beatle
      x1
      y1
      x2
      y2
      frame
      frametimer
      directionleft
      facing
      landed               ;is able to fall off or walk off edges
      falling         ;is able to fall
   endtype
      

dim zingers(32) as zinger

for temp=1 to 32
   zingers(temp).frame=1
   zingers(temp).frametimer=timer()+30
   zingers(temp).x1=rndrange(0, 500)
   zingers(temp).y1=rndrange(0, 400)
   zingers(temp).facing=rndrange(1, 2)
   zingers(temp).directionleft=30
   next temp   
   
   dim beatles(50) as beatle
   for temp=1 to 50
      beatles(temp).frame=1
      beatles(temp).frametimer=timer()+30
      beatles(temp).facing=rndrange(1, 2)
      beatles(temp).falling=true
      beatles(temp).landed=false
      beatles(temp).x1=rndrange(0, 500)
      beatles(temp).y1=rndrange(0, 400)
   next temp

dixieaction=1
jumpframe=1
dixieblasted=false
;for editing stuff right here <

current_blast_barrel=1

;>


   

SCROLLX=0
SCROLLY=0
MAPWIDTH=roundup(WIDTH/16)
MAPHEIGHT=roundup(HEIGHT/16)
dim map(MAPWIDTH, MAPHEIGHT)
dim TILEMAP(MAPWIDTH/2, MAPHEIGHT/2) ;32 by 32 pixel tiles
spritewidth=35
spriteheight=25
dixieframe=1
frametimer=timer()+30
maxfallspeed=12
falltimer=timer()+200  ;.5 miliseconds for falling increase
wallspeed=25
charx=400
chary=12128
falling=false
walltimer=timer()+wallspeed
spunalready=false
spinning=false
MODE$="View"

type solid_tile
   x1
   y1
   x2
   y2
endtype
   
   type barrel
      x1
      y1
      x2
      y2
      falling
      landed
      fallspeed
      draw
      falltimer
endtype

type blast_barrel
   x1
   y1
   x2
   y2
   facing_type
   blast_range
endtype

dim b_barrels(30) as blast_barrel
for temp=1 to 30
   b_barrels(temp).facing_type=1
next temp
   


dim barrels(100) as barrel
for temp=1 to 100
   barrels(temp).fallspeed=1
   barrels(temp).falling=true
   barrels(temp).landed=false
   barrels(temp).x1=rndrange(0, 640)
   barrels(temp).y1=rndrange(0, 640)
   barrels(temp).draw=true
   barrels(temp).falltimer=timer()+100
next temp



   

dim solids(MAPWIDTH, MAPHEIGHT) as solid_tile
read=false
if fileexist("C:\brambles_map2.txt") then read=true

IF READ=TRUE
readfile "C:\brambles_map2.txt", 1
ink rgb(0, 0, 255)
tile_to_read=1
totaltiles=MAPWIDTH*MAPHEIGHT
rendertoscreen

charx=readint(1)
chary=readint(1)
for tempx=1 to MAPWIDTH
   for tempy=1 to MAPHEIGHT
      map(tempx, tempy)=readint(1)
      solids(tempx, tempy).x1=readint(1)
      solids(tempx, tempy).y1=readint(1)
      solids(tempx, tempy).x2=readint(1)
      solids(tempx, tempy).y2=readint(1)
      x1=solids(tempx, tempy).x1
      y1=solids(tempx, tempy).y1
      x2=solids(tempx, tempy).x2
      y2=solids(tempx, tempy).y2
      ;rendertoimage castle
      ;box x1, y1, x2, y2,
      ;rendertoscreen
      
      
      ;tile_to_read=tile_to_read+1
next tempy
      print "Loading SOLID TILE DATA PLEASE WAIT "
      print "Reading Across X: "+str$(tempx)
      print "Total Reads remaining: "+str$(MAPWIDTH-tempx)
      percent#=((tempx*100)/MAPWIDTH)
      print "Percent completed "+str$(percent#)
      ink rgb(0, 0, 255)
      box 200, 50, 200+(percent#)*5, 60, 1
      ink rgb(0, 255, 0)
      box 200, 50, 200+100*5, 60, 0
      
      sync
      cls rgb(0,0,0)   
next tempx

for tempx=1 to MAPWIDTH/2
   for tempy=1 to MAPHEIGHT/2
      TILEMAP(tempx, tempy)=readint(1)
   next tempy
next tempx

for temp=1 to 30
   b_barrels(temp).x1=readint(1)
   b_barrels(temp).y1=readint(1)
   b_barrels(temp).x2=readint(1)
   b_barrels(temp).y2=readint(1)      
next temp
   

closefile 1

   falling=true
   mode$="playmode"

   ENDIF
      

myimage=newfximage(640, 480)
;imagemaskcolour myimage, rgb(255, 0, 255) ;purple ish?
rendertoimage myimage
cls rgb(255, 255, 255)
imagemaskcolour myimage, rgb(255, 255, 255);  white



rendertoimage castle

if grid=true
for tempx=1 to WIDTH/16
   for tempy=1 to HEIGHT/16
      ink rgb(255,255, 255)
      box (tempx-1)*16, (tempy-1)*16, tempx*16, tempy*16, 0
   next tempy
next tempx   
endif
   
      


rendertoscreen

do

      
   

         scrollimage sky, -1, 0
                        
   
   if enterkey()
      chary=1
      scrolly=0
   endif
      
      if dixieblasted=false
   if falling=true
      if timer()>falltimer
         fallspeed=fallspeed+1
         if spinning=true
         falltimer=timer()+400
         else
         falltimer=timer()+200
         endif
         
         if fallspeed>maxfallspeed then fallspeed=maxfallspeed
      endif
   endif
         endif
               if dixieholdingbarrel=true
               if spacekey()
                  if downkey()
                     puttingdown=true
                     pickingup=false
                  endif
               endif
            endif   
   
                  
   
   ;for temp=1 to 300
      ;pushbananaframe(temp)
      ;next temp
   
   ;if timer()>walltimer
      ;walltimer=timer()+wallspeed
   
   ;if falling=true
   ;if chary=>wally-spriteheight-1
   ;   chary=wally-spriteheight-1
      ;landed=true
   ;   falling=false
      ;onwall=true
;   else
   ;   onwall=false   
;endif
;endif   


   
      
      if jump=false
         if falling=false
            if onwall=true
               ;chary=chary-1
            endif
         endif
      endif
      
   ;   wally=wally-1
   ;scrolly=scrolly-1      
      
      
   
   
   if mode$="playmode"
   if onwall=true
      
            ;pan camera down slowly
               if scrolly<wally-400
                  scrolly=scrolly+2
                  scrollimage backdrop, 0, -2
                  scrollimage sky, 0, 1
               else   
      scrolly=wally-400
            endif
      if scrolly>11776 then scrolly=11776
   endif   
   endif   
      

   


         

;draw map


;render to the map image
rendertoscreen


         
rendertoimage castle

x=mousex()
y=mousey()

if SCROLLX=>16
   amountx=roundup(SCROLLX/16)
else
   amountx=1
endif
   ;top side same thing as above
if SCROLLY=>16
   amounty=roundup(SCROLLY/16)
else
   amounty=1
endif






moveright=true
moveleft=true

      screenx1=amountx
      screeny1=amounty
      screenx2=32+amountx
      screeny2=30+amounty
      screenx1=screenx1*16
      screeny1=screeny1*16
      screenx2=screenx2*16
      screeny2=screeny2*16


for tempx=amountx to 32+amountx  ;disable x scroll for this entirely for the right side
   for tempy=amounty to 30+amounty
      
      x=(tempx-1)*16
      y=(tempy-1)*16
      
      xdraw=x-SCROLLX
      ydraw=y-SCROLLY
      ink rgb(0, 255, 0)
      ;box x, y, x+16, y+16, 0
            
            ;check solid tiles below character
            
            
            
            ;check player on tile
                     
                     checkingx=tempx
                     checkingy=tempy
                     if checkingx>MAPWIDTH then checkingx=MAPWIDTH
                     if checkingy>MAPHEIGHT then checkingy=MAPHEIGHT
                  
                  if map(checkingx, checkingy)=1       ;if the tile is solid, check against player collision         
                     
                     
               checkingx1=solids(checkingx, checkingy).x1
               checkingy1=solids(checkingx, checkingy).y1
               checkingx2=solids(checkingx, checkingy).x2
               checkingy2=solids(checkingx, checkingy).y2
                  
                  
                  
               
               
                        
               
               
                           
                           playerx1=charx
                           playery1=chary
                           playerx2=charx+spritewidth
                           playery2=chary+spriteheight
                           
                           if spinning=true
                              gspeed=fallspeed/2
                              if gspeed>maxhelicopterfall then gspeed=maxhelicopterfall
                              else
                                 gspeed=fallspeed
                           endif
                        
                                       
                           
                           if playerx2>checkingx1         ;the players x coordinates align
                           if playerx1<checkingx2                  
                                    if playery1<checkingy1 ;the players top edge is not past the top of the platform
                                 if playery2>checkingy1-gspeed ;the players bottom edge IS past the top of the platform-1 pixel
                                       landed=true
                                       fallspeed=1
                                       spunalready=false
                                       spinning=false
                                       spinframe=1
                                       spinfallspeed=0
                                       falling=false
                                    endif
                                 endif
                           endif
                        endif
                              
                                       
                                 
                           
                              ;check for left and right sides
                  ;check left collision (Player is here --> ||Colliding with LEFT wall of object)

                                             
                     if playerx2>checkingx1-4
                        if playerx2<checkingx1+4
                           if playery2>checkingy1
                              if playery1<checkingy2
                                 moveright=false
                              else
                                 moveright=true
                              endif
                           endif
                        endif
                     endif
                                    
                                    ;check right collision
                     if playerx1>checkingx2-4
                        if playerx1<checkingx2+4
                           if playery2>checkingy1
                              if playery1<checkingy2
                                 moveleft=false
                              else
                                 moveleft=true
                              endif
                           endif
                        endif
                     endif
                                    
                     
                           
                           
                           
                           
                  endif
                  
                  
                     
                     
                     
                  
                              
                                                                        
            
                              
            
            
            if mode$="Collision"         ;only place tiles if mode is collision
            
            
            
            
            
            if mouseinbox(xdraw, ydraw, xdraw+16, ydraw+16)
               if rightmousebutton()
                  charx=x
                  chary=y
               endif
               endif   
               
            
            if menu=1
      if leftmousebutton()
         if mouseinbox(xdraw, ydraw,xdraw+16, ydraw+16)
            box x, y, x+16, y+16, 0
            map(checkingx, checkingy)=1
            solids(checkingx, checkingy).x1=x
            solids(checkingx, checkingy).y1=y
            solids(checkingx, checkingy).x2=x+16
            solids(checkingx, checkingy).y2=y+16
         endif
endif
endif


            
                  
   
            endif   
            
      
      
   next tempy
next tempx





for temp=1 to 100 ;check barrel collision
   
   
                                 
                                 
                           x1=barrels(temp).x1
                           y1=barrels(temp).y1
                           x2=x1+barrelwidth
                           y2=y1+barrelheight
                           
                           
                           if mouseinbox(x1-scrollx, y1-scrolly, x2-scrollx, y2-scrolly)
                              inbox=true
                              lastbarrelx1=x1
                              lastbarrely1=y1
                              lastbarrelx2=x2
                              lastbarrely2=y2
                              lastbarrelnumber=temp
                              
                              text 200, 570, "Barrel number= "+str$(lastbarrelnumber)
                              text 200, 580, "Barrel X1= "+str$(x1) +"Barrel X2= "+str$(x2)
                              text 200, 590, "Barrel Y1= "+str$(y1) +"Barrel Y2= "+str$(y2)
                                 if spacekey()
                                 barrels(temp).x1=mousex()+scrollx-20
                                 barrels(temp).y1=mousey()+scrolly-20
                                 endif
                        endif
                           
                              
                              
                           
                           amountx=x1
                           amounty=y1
                           amountx=roundup(amountx/16) ;get the tile number of x
                           amounty=roundup(amounty/16) ;get the tile number of y
                           
                           for tempx=amountx-3 to amountx+3
                              for tempy=amounty-3 to amounty+3
                                 
                                          checkingx=tempx
                                          checkingy=tempy
                                          if checkingx>MAPWIDTH then checkingx=MAPWIDTH
                                          if checkingy>MAPHEIGHT then checkingy=MAPHEIGHT
                                                
                                                if checkingx<1 then checkingx=1
                                                if checkingy<1 then checkingy=1
                                                
                                                if map(checkingx, checkingy)=1       ;if the tile is solid, check against player collision         
                     
                     
               checkingx1=solids(checkingx, checkingy).x1
               checkingy1=solids(checkingx, checkingy).y1
               checkingx2=solids(checkingx, checkingy).x2
               checkingy2=solids(checkingx, checkingy).y2
                           
                           bspeed=barrels(temp).fallspeed
                                                               ;only try to handle barrels on screen
                        
                                          
                           
                           
                           
                     
                           if x2>checkingx1      
                           if x1<checkingx2                  
                           if y1<checkingy1
                           if y2>checkingy1-checkspeed
                                       barrels(temp).landed=true
                                       barrels(temp).fallspeed=1
                                       barrels(temp).falling=false
                                    endif
                                 endif
                           endif
                     endif
                                    endif
                                    
                                    next tempy
                                    next tempx   
                                          
                           
                           
                           
                           
                           
                           playerx1=charx
                           playery1=chary
                           playerx2=charx+spritewidth
                           playery2=chary+spriteheight
                           
                           
                           if dixieaction=1 ;facing right
                           
                           
                           
                           
                        if playerx2>x1-3
                        if playerx2<x1+3
                        if playery2>y1
                        if playery1<y2
                                       if spacekey()    ;check if dixie is on right side of barrel and holding space key
                                       if landed=true
                                 dixieholdingbarrel=true
                                 barrels(temp).draw=false
                                 dixiepickupbarrelframe=1
                                 pickingup=true
                                 pickedupbarrel=temp
                              endif
                           endif
                        endif
                  endif
               endif   
            endif
                  
                  
               endif
                  
                  
                  if dixieaction=2         ;facing left
                     
                     
                     if playerx1>x2-3
                        if playerx1<x2+3
                           if playery2>y1
                              if playery1<y2
                                 if spacekey()      ;check if dixie is on left side of barrel and holding space key
                                       if landed=true
                                 dixieholdingbarrel=true
                                 barrels(temp).draw=false
                                 dixiepickupbarrelframe=1
                                 pickingup=true
                                 pickedupbarrel=temp
                                 
                              endif
                           endif
                        endif
                  endif
               endif
            endif
                     
                     endif
                           
                           
                                 
                           
                           next temp


               
                  for temp=1 to 32
                     x1=zingers(temp).x1
                     y1=zingers(temp).y1
                     frame=zingers(temp).frame
                     ftimer=zingers(temp).frametimer
                     directionleft=zingers(temp).directionleft
                     facing=zingers(temp).facing
                        if timer()>ftimer
                        
                     zingers(temp).frame=zingers(temp).frame+1
                     zingers(temp).frametimer=timer()+30
                     
                     
                              
                           zingers(temp).directionleft=zingers(temp).directionleft-1   
                     
                     endif
                     
                           select facing
                        case 1
                           zingers(temp).x1=zingers(temp).x1-3
                           
                           if directionleft<=0
                              zingers(temp).facing=2
                              zingers(temp).directionleft=30
                           endif
                           
                           
                           case 2
                              zingers(temp).x1=zingers(temp).x1+3
                              
                              if directionleft<=0
                              zingers(temp).facing=1
                              zingers(temp).directionleft=30
                              endif
                     endselect
                     
                     
                     if zingers(temp).frame>3 then zingers(temp).frame=1
                     next temp
                     
                     
                     for temp=1 to 50
                        x1=beatles(temp).x1
                        y1=beatles(temp).y1
                        x2=x1+48
                        y2=y1+32
                        ;landed=beatles(temp).landed    ;today I found this glitch. The players collision check WAS registering. But this bugger was changing it to whatever the value of the last beatle checked is. BUGGER!
                        
                        falling=beatles(temp).falling
                        ftimer=beatles(temp).frametimer
                        facing=beatles(temp).facing
                        
                           if timer()>ftimer
                        
                     beatles(temp).frame=beatles(temp).frame+1
                     beatles(temp).frametimer=timer()+30
                     endif
                     
                           if beatles(temp).frame>8 then beatles(temp).frame=1
                     
                           amountx=x1
                           amounty=y1
                           amountx=roundup(amountx/16) ;get the tile number of x
                           amounty=roundup(amounty/16) ;get the tile number of y
                           
                           for tempx=amountx-2 to amountx+2
                              for tempy=amounty-2 to amounty+2
                                 
                                          checkingx=tempx
                                          checkingy=tempy
                                          if checkingx>MAPWIDTH then checkingx=MAPWIDTH
                                          if checkingy>MAPHEIGHT then checkingy=MAPHEIGHT
                                                
                                                if checkingx<1 then checkingx=1
                                                if checkingy<1 then checkingy=1
                                                
                                                if map(checkingx, checkingy)=1       ;if the tile is solid, check against beatle collision      
                     
                     
               checkingx1=solids(checkingx, checkingy).x1
               checkingy1=solids(checkingx, checkingy).y1
               checkingx2=solids(checkingx, checkingy).x2
               checkingy2=solids(checkingx, checkingy).y2
                           
                           cpseed=3
                                                            
                        
                                          
                           
                           
                           
                     
                           if x2>checkingx1      
                           if x1<checkingx2                  
                           if y1<checkingy1
                           if y2>checkingy1-cspeed
                                       beatles(temp).landed=true
                                       beatles(temp).falling=false
                                    endif
                                 endif
                           endif
                     endif
                                    endif
                                    
                                    next tempy
                                    next tempx
                  
                     
                  
                  
                  
                  
                  next temp   


            
            
            if mode$<>"playmode"
            if rightkey()
               scrollx=scrollx+12
               scrollimage backdrop, -6, 0
               scrollimage sky, -3, 0
               
            endif
            
            if leftkey()
               scrollx=scrollx-12
               scrollimage backdrop, 6, 0
               scrollimage sky, 3, 0
         endif
         
      endif
            



               if falling=true                     ; set the spinning flag if falling and upkey is pressed
      if spinning=false
         if spunalready=false
            if landed=false
            if spacekey()
               spinning=true
               spunalready=true
               oldfallspeed=fallspeed
               fallspeed=1
            endif
         endif
      endif
endif
endif
   
   
                           ; if upkey is held player is spinning
   if falling=true or jump=true
      if spinning=true
         if spunalready=true
            if landed=false
            if spacekey()   
            spinning=true
            oldfallspeed=fallspeed
            jump=false
         else
            spinning=false
            fallspeed=oldfallspeed
         endif
      endif
endif
endif   
endif



   if spinning=true
      if timer()>spinframetimer
         spinframetimer=timer()+30
         spinframe=spinframe+1
         if spinframe>10 then spinframe=1
         endif
      endif            
                        
                        
                        if dixieholdingbarrel=true            ;this handles dixie's frame animations for her facing right direction while picking up a barrel!
                           if pickingup=true
                           
                           if dixiepickupbarrelframe<14         ;she can't move while picking things up!!! silly dixie kong
                              moveright=false
                              moveleft=false
                              jump=false
                              jumptime=0
                           else
                              moveright=true
                     endif
                     
                                    
                                    if timer()>bholdframetimer
                           bholdframetimer=timer()+30
                           dixiepickupbarrelframe=dixiepickupbarrelframe+1
                           endif
                           
                           if dixiepickupbarrelframe>14 then dixiepickupbarrelframe=14
                           endif
                                    
                        
                        endif   
                                 
                           
                           
                  
                              
                              
                                    if puttingdown=true
                                       
                                       if dixiepickupbarrelframe>1
                                          moveright=false
                                          moveleft=false
                                          jump=false
                                          jumptime=0
                                       else
                                          moveright=true
                                          moveleft=true
                                       endif
                                       
                                       if timer()>bholdframetimer
                                          bholdframetimer=timer()+30
                                          dixiepickupbarrelframe=dixiepickupbarrelframe-1
                                       endif
                                       
                                       if dixiepickupbarrelframe<=1
                                          dixiepickupbarrelframe=1
                                          dixieholdingbarrel=false
                                          puttingdown=false
                                          pickingup=false
                                          if dixieaction=1 ;facing right
                                          barrels(pickedupbarrel).x1=charx+spritewidth-4
                                          else
                                          if dixieaction=2 ;facing left   
                                          barrels(pickedupbarrel).x1=charx-spritewidth+4
                                          endif
                                          endif                              
                                          barrels(pickedupbarrel).y1=chary-spriteheight+8
                                          barrels(pickedupbarrel).draw=true
                                          barrels(pickedupbarrel).falling=true
                                          barrels(pickedupbarrel).landed=false
                                       endif
                                          
                                          
                                          
                                       endif
                     
                           
                        
                        
                        

                  if mode$="playmode"
                     if jump=false
               if landed=false
                  if dixieblasted=false
            ;handle character falling
                  if falling=true
                     
                     if spinning=true
                        spinfallspeed=fallspeed/2
                        
                        ;quick patch fall speed to max helicopter speed
                        
                        ;only fall if dixieblasted=false
                        
                        if spinfallspeed>maxhelicopterfall then spinfallspeed=maxhelicopterfall
                        
                        
                     chary=chary+spinfallspeed
                  else
                     chary=chary+fallspeed   
                  endif
                     
                        
                     if chary=>480/2         ;sloppy attempt at keeping the player centered on camera
                        
                        if spinning=false
                        scrolly=scrolly+fallspeed
                        scrollimage backdrop, 0, -fallspeed
                        scrollimage sky, 0, -fallspeed/2
                     else
                        scrolly=scrolly+spinfallspeed
                        scrollimage backdrop, 0, -spinfallspeed
                        scrollimage sky, 0, -spinfallspeed/2
                     endif
                     endif
                        
                  endif
                  
                     
               
                     
               
               
               
            endif ;only execute character falling code if landed is false.
         endif
               
            endif         ;end the code for jumping
                  
                  
                     endif
                        
                     
                     
                              
                     
            ink rgb(0, 0, 255); blue

   
   ink rgb(255, 255, 255)
      


      ;for temp=1 to roundup(640/163)
      ;drawimage wall, (temp-1)*163, wally, 0
         ;next temp
         
         
      
         
      ;rendertoimage myimage
      
      
      ;getimage myimage, 0+scrollx, 0+scrolly, 640+scrollx , 480+scrolly
      
      
      
      ;make sure it doesn't scroll past the left or right side too far
      if scrollx<=0 then scrollx=0
      ;if scrollx+640=>WIDTH then scrollx=WIDTH-640

      ;make sure it doesn't scroll past the top or bottom side too far
      if scrolly<=0 then scrolly=0
      if scrolly+480=>HEIGHT then scrolly=HEIGHT-480
   
         
         
         
      
      rendertoscreen
      ;box charx, chary, charx+16, chary+16, 0
      charx1=charx
      chary1=chary
      charx2=charx+spritewidth
      chary2=chary+spriteheight
      charx1=charx1-scrollx
      chary1=chary1-scrolly
      charx2=charx2-scrollx
      chary2=chary2-scrolly
      
      
      
      
      for tempx=1 to 2
         for tempy=1 to 2
         drawimage sky, (tempx-1)*256, (tempy-1)*256, 0
            drawimage backdrop, (tempx-1)*256, (tempy-1)*256, 1
      next tempy
      next tempx   
         
            
      
      drawimage myimage, 0, 0, 1
      drawimage mode, 0, 500, 0
      drawimage save, 0, 600, 0
      drawimage playmode, 0, 700, 0
      
      if timer()>bananatimer
         bananatimer=timer()+30
         pushframes=true
      endif
         
      
      for temp=1 to 50
         number=temp
         frame=bananas(temp).frame
         x=bananas(temp).x
         y=bananas(temp).y
         collected=bananas(temp).collected
         if collected=false
         drawimage bananaframes(frame), x-scrollx, y-scrolly, 1
         if pushframes=true
         pushbananaframe(number)
         endif
         endif
         
         
         if charx+spritewidth=>x
            if chary+spriteheight=>y
               if charx<x+16
                  if chary<y+16
                     bananas(temp).collected=true
                  endif
               endif
            endif
         endif
                     
         
      next temp
      
      
      amountx=roundup(tileboxoffsetx/32)
      if amountx<1 then amountx=1
      ink rgb(255, 0, 0)
      tile_to_draw=amountx*26
      for tempx=amountx to 23+amountx
         for tempy=1 to 26
            if tile_to_draw>598 then tile_to_draw=598
            if tile_to_draw<1 then tile_to_draw=1
            
            if menu=1
            drawimage tiles(tile_to_draw), (tempx-1)*32+530-tileboxoffsetx, (tempy-1)*32-tileboxoffset, 0
            endif
            
            
            ;dx1=((tempx-1)*32)+530-tileboxoffsetx
            ;dy1=(tempy-1)*32-tileboxoffset
            ;dx2=(tempx*32)+530-tileboxoffsetx
            ;dy2=tempy*32-tileboxoffset
            ;boxc dx1, dy1, dx2, dy2, 0, rgb(255, 0, 0)
                  
            if mouseinbox( ((tempx-1)*32)+530-tileboxoffsetx, (tempy-1)*32-tileboxoffset, (tempx*32)+530-tileboxoffsetx, tempy*32-tileboxoffset )
                  if leftmousebutton()
                     if menu=1
                     currenttile=tile_to_draw
                     endif
                  endif
            endif
         tile_to_draw=tile_to_draw+1
                     
         next tempy
      next tempx   
      
      
      if SCROLLX=>16
   amountx=roundup(SCROLLX/16)
else
   amountx=1
endif
   ;top side same thing as above
if SCROLLY=>16
   amounty=roundup(SCROLLY/16)
else
   amounty=1
endif

for tempx=amountx to 32+amountx  ;disable x scroll for this entirely for the right side
   for tempy=amounty to 30+amounty
      
      draw=map(tempx, tempy)
      
      if draw=1
      
      x=(tempx-1)*16
      y=(tempy-1)*16
      
      xdraw=x-SCROLLX
      ydraw=y-SCROLLY
      ink rgb(0, 255, 0)
      box xdraw, ydraw, xdraw+16, ydraw+16, 0
   endif
      
      
next tempy
next tempx      


      
      
      if SCROLLX=>32
   amountx=roundup(SCROLLX/32)
   else amountx=1
endif
   ;top side same thing as above
if SCROLLY=>32
   amounty=roundup(SCROLLY/32)
else
   amounty=1
endif

for tempx=amountx to amountx+17
   for tempy=amounty to amounty+16
      
      
      x=(tempx-1)*32
      y=(tempy-1)*32
      
      xdraw=x-SCROLLX
      ydraw=y-SCROLLY
      
                  if TILEMAP(tempx, tempy)>0
         
               tile_this_tile=TILEMAP(tempx, tempy)
                  
                  drawimage tiles(tile_this_tile), xdraw, ydraw, 1
                  endif
                        
                              if mode$="tile_mode"
                                 
                                 if mouseinbox(0 ,0 ,500, 480)
                        if mouseinbox( xdraw, ydraw, xdraw+32, ydraw+32 )
                              if leftmousebutton()
                                    TILEMAP(tempx, tempy)=currenttile
                                 endif
                              endif
                                    ;sync
                              endif
                           endif
                                 
                                    
                     
               next tempy
         next tempx
         
         
         
         
      
            
            
            
   
            
         
         
         
      
      ink rgb(0, 0, 255)      ;blue character
      ;box charx1, chary1, charx2, chary2, 1
      box charx1, chary1, charx2, chary2, 0
      
               if dixieaction=1                  ;only draw if dixie is facing right
               if dixieholdingbarrel=true   
               drawimage dixiepickupbarrelright(dixiepickupbarrelframe), charx1, chary1-48, 1
               endif
               endif   
               
      
      if dixieholdingbarrel=false
      if dixieaction=1
      if landed=true
      drawimage dixieright(dixieframe), charx1, chary1-spriteheight/2, 1
   else
            
            
            if jump=true   
      drawimage dixiejumpright(jumpframe), charx1, chary1-36, 1
      else
      if spinning=false   
      drawimage dixiejumpright(4), charx1, chary1-36, 1
      else
      
      drawimage dixiespinright(spinframe), charx1, chary1-spriteheight/2, 1
      
      endif   
      endif
      endif
   endif
endif


               if dixieaction=2               ;only draw if dixie is facing left
               if dixieholdingbarrel=true   
               drawimage dixiepickupbarrelleft(dixiepickupbarrelframe), charx1-spritewidth, chary1-48, 1
               endif
               endif   

      if dixieholdingbarrel=false
      if dixieaction=2
      if landed=true
      drawimage dixieleft(dixieframe), charx1-16, chary1-spriteheight/2, 1
      else
            if jump=true
      drawimage dixiejumpleft(jumpframe), charx1-16, chary1-36, 1   
      else
      if spinning=false   
      drawimage dixiejumpleft(4), charx1-16, chary1-36, 1
      else
               
         drawimage dixiespinleft(spinframe), charx1, chary1-spriteheight/2, 1
      
      endif   
      endif
      endif
      endif
      endif   
            
      ink rgb(0, 255, 255) ;white
      
      
      if keystate(72)
               tileboxoffset=tileboxoffset-5
            endif   
                  
         if keystate(80)
               tileboxoffset=tileboxoffset+5
         endif
         
         
            if keystate(77)
               tileboxoffsetx=tileboxoffsetx+5
            endif
            
               if keystate(75)
                  tileboxoffsetx=tileboxoffsetx-5
            endif
            
            if keystate(42)
               menu=menu-1
            endif
            
            if keystate(54)
               menu=menu+1
            endif
            
            if menu<1 then menu=1
            if menu>2 then menu=2         
                     
         
         
                  
      
      
text 200, 500, "SCROLLY " +str$(Scrolly)+" --ROUNDED to tile index: "+str$(amounty)
text 200, 520, "SCROLLX " +str$(Scrollx)+" --ROUNDED to tile index: "+str$(amountx)
text 200, 540, "This is the result of WIDTH <> scroll X"+str$(WIDTH-(640+scrollx))+"and"+str$(WIDTH)
text 200, 560, "Playerx : "+str$(charx)+" Playery : "+str$(chary)

                        if inbox=true
                              text 200, 570, "Barrel number= "+str$(lastbarrelnumber)
                              text 200, 580, "Barrel X1= "+str$(x1) +"Barrel X2= "+str$(x2)
                              text 200, 590, "Barrel Y1= "+str$(y1) +"Barrel Y2= "+str$(y2)
                           endif
                              
circle mousex(), mousey(), 8, 0



if mouseinbox(0, 500,  0+128, 564)
   if leftmousebutton()
      mode$="Collision"
   endif
endif

if mouseinbox(0, 700, 0+(128*3), 764)
   if leftmousebutton()
      mode$="playmode"
      falling=true
   endif
endif
      

   if mouseinbox(0, 600, 0+(128*2), 664)
      if leftmousebutton()
            
            if fileexist("C:/brambles_map2.txt")
            deletefile ("C:/brambles_map2.txt")
         endif
               
            
               writefile "C:/brambles_map2.txt", 1
               
               writeint 1, charx
               writeint 1, chary
            
            for tempx=1 to Mapwidth
               for tempy=1 to mapheight
                  writeint 1, map(tempx, tempy)
                  writeint 1, solids(tempx, tempy).x1
                  writeint 1, solids(tempx, tempy).y1
                  writeint 1, solids(tempx, tempy).x2
                  writeint 1, solids(tempx, tempy).y2
               next tempy
         next tempx
                  
                  for tempx=1 to MAPWIDTH/2
                     for tempy=1 to MAPHEIGHT/2
                     writeint 1, TILEMAP(tempx, tempy)
                     next tempy
                        next tempx

for temp=1 to 30
   writeint 1, b_barrels(temp).x1
   writeint 1, b_barrels(temp).y1
   writeint 1, b_barrels(temp).x2
   writeint 1, b_barrels(temp).y2
next temp
            
            closefile 1
                  
         
      endif
      endif   

      

;scrolling input




if leftkey()
   ;scrollx=scrollx-8
   dixieaction=2
   if timer()>frametimer
   dixieframe=dixieframe+1
   
   if dixieframe>16 then dixieframe=1
   frametimer=timer()+30
endif

if moveleft=true   
   
   
   charx=charx-4
   if charx>320
   if charx<WIDTH-320
   scrollimage backdrop, 2, 0
   scrollimage sky, 1, 0
   endif
   endif   
   
   ;scrollx=scrollx-1

endif

endif



      
if rightkey()
   ;scrollx=scrollx+8
   dixieaction=1
   if timer()>frametimer
   dixieframe=dixieframe+1
   
   if dixieframe>16 then dixieframe=1
   frametimer=timer()+30
   endif
   
   if moveright=true
   charx=charx+4
   if charx<WIDTH-320
   if charx>320
   scrollimage backdrop, -2, 0
   scrollimage sky, -1, 0
endif
endif
   
   ;scrollx=scrollx+1


endif

   

endif

      if mode$<>"playmode"
      
      if downkey()
         scrolly=scrolly+12
         scrollimage backdrop, 0, -6
         scrollimage sky, 0, -3
      endif
   
      if upkey()
      scrolly=scrolly-12
      scrollimage backdrop, 0, 6
      scrollimage sky, 0, 3
      endif

endif
   
         
         
               if mode$="playmode"
                  
                  
            if jump=false
            if upkey()
               if landed=true
            jump=true
            upforce=95
            jumpframetimer=timer()+200
      endif
endif
endif
   
      
            
         
         
         
            if jump=true
               
               
               chary=chary-2
               upforce=upforce-2
               scrolly=scrolly-2
               scrollimage backdrop, 0, 2
               scrollimage sky, 0, 1
               if timer()>jumpframetimer
                  jumpframe=jumpframe+1
                  if jumpframe>4 then jumpframe=4
                  jumpframetimer=timer()+200
      endif
   endif   
         
         if jump=true
         if upforce=<0
            jump=false
            falling=true
            landed=false
            upforce=0
            endif
            endif   
            
            
            
            endif
               
            

      falling=true
      landed=false
      ;moveright=true
      pushframes=false
      
      
      ;draw barrels
      for temp=1 to 100
         x=barrels(temp).x1
         y=barrels(temp).y1
         bfalling=barrels(temp).falling
         blanded=barrels(temp).landed
         draw=barrels(temp).draw
         btimer=barrels(temp).falltimer
         
            
         
         if blanded=false
            if bfalling=true
               
               
               if timer()>btimer
                  barrels(temp).falltimer=timer()+100
                  barrels(temp).fallspeed=barrels(temp).fallspeed+1
                  if barrels(temp).fallspeed>3 then barrels(temp).fallspeed=3
                  endif
                        
                        bfallspeed=barrels(temp).fallspeed
                        barrels(temp).y1=barrels(temp).y1+bfallspeed
               
            endif
         endif
               
               if draw=true
         
         drawimage barreli, x-scrollx, y-scrolly, 1
               endif
                  
      
         
      next temp
      
         for temp=1 to 32
            frame=zingers(temp).frame
            facing=zingers(temp).facing
            select facing
               case 1
            drawimage zingerfacesleft(frame), zingers(temp).x1-scrollx, zingers(temp).y1-scrolly, 1
               case 2
            drawimage zingerfacesright(frame), zingers(temp).x1-scrollx, zingers(temp).y1-scrolly, 1
            endselect
         next temp
            
            for temp=1 to 50
               frame=beatles(temp).frame
               facing=beatles(temp).facing
               blanded=beatles(temp).landed
               bfalling=beatles(temp).falling
               
               if blanded=false
                  if bfalling=true
                     if mode$="playmode"
                     beatles(temp).y1=beatles(temp).y1+3
                  endif
            endif
               endif   
                     
               
               select facing
                  case 1
                        if blanded=true
                     beatles(temp).x1=beatles(temp).x1-2
                     endif
                     drawimage beatlefacesleft(frame), beatles(temp).x1-scrollx, beatles(temp).y1-scrolly, 1
                     case 2
                        if blanded=true
                        beatles(temp).x1=beatles(temp).x1+2
                        endif
                        drawimage beatlefacesright(frame), beatles(temp).x1-scrollx, beatles(temp).y1-scrolly, 1
                  endselect
                  
                  beatles(temp).falling=true
                  beatles(temp).landed=false   
                     
               next temp   
      

            if menu=2
            drawimage barrel_(1), 564, 0, 1
            drawimage barrel_(2), 628, 0, 1
            drawimage barrel_(3), 564, 64, 1
            drawimage barrel_(4), 628, 64, 1
            
            
            if mouseinbox(564, 0, 628, 64)
               if leftmousebutton()
                  barrel_selected=1
               endif
            endif
            
            if mouseinbox(628, 0, 692, 64)
               if leftmousebutton()
                  barrel_selected=2
               endif
            endif
            
            if mouseinbox(564, 64, 628, 128)
               if leftmousebutton()
                  barrel_selected=3
               endif
            endif
            
            if mouseinbox(628, 64, 692, 128)
               if leftmousebutton()
                  barrel_selected=4
               endif
            endif
            
            
            if leftmousebutton()
               testing_barrel_x=mousex()+scrollx
               testing_barrel_y=mousey()+scrolly
               
            endif
                  
                  if barrel_selected<1 then barrel_selected=1
                  drawimage barrel_(barrel_selected), testing_barrel_x-scrollx, testing_barrel_y-scrolly, 1               
            
                     
                     if rightmousebutton()
                        b_barrels(current_blast_barrel).x1=testing_barrel_x
                        b_barrels(current_blast_barrel).y1=testing_barrel_y
                        b_barrels(current_blast_barrel).x2=testing_barrel_x+64
                        b_barrels(current_blast_barrel).y2=testing_barrel_y+64
                        b_barrels(current_blast_barrel).facing_type=barrel_selected
                        menu=1
                        current_blast_barrel=current_blast_barrel+1
                     endif
                     
                     
            endif
      
      
            for temp=1 to 30
               checkingx1=b_barrels(temp).x1
               checkingy1=b_barrels(temp).y1
               checkingx2=b_barrels(temp).x2
               checkingy2=b_barrels(temp).y2
               
               
               
               
               
               facing=b_barrels(temp).facing_type
               drawimage barrel_(facing), checkingx1-scrollx, checkingy1-scrolly, 1
               box checkingx1-scrollx, checkingy1-scrolly, checkingx2-scrollx, checkingy2-scrolly, 0
               
               
               playerx1=charx
               playery1=chary
               playerx2=charx+spritewidth
               playery2=chary+spriteheight
               
               ;if playerx2>checkingx1-3
                     ;   if playerx2<checkingx2
                           ;if playery2>checkingy1
                              ;if playery1<checkingy2
                                 ;dixieblasted=true
                                 ;dixieblasteddirection=b_barrels(temp).facing_type
                                 ;dixieblastedspeed=5
                           ;   endif
                           ;endif
                     ;   endif
                  ;   endif
                                    
                                    ;check right collision
                     ;if playerx1>checkingx2-3
                        ;if playerx1<checkingx2+3
                           ;if playery2>checkingy1
                              ;if playery1<checkingy2
                                 ;dixieblasted=true
                                 ;dixieblasteddirection=b_barrels(temp).facing_type
                                 ;dixieblastedspeed=5
                              ;endif
                           ;endif
                        ;endif
                     ;endif
                              
                              
                              
                              if playerx2=>checkingx1
                                 if playerx1<=checkingx2
                                    if playery2=>checkingy1
                                       if playery1<=checkingy2
                                          dixieblasted=true
                                             dixieblasteddirection=b_barrels(temp).facing_type
                                                dixieblastedspeed=50
                                             endif
                                          endif
                                       endif
                                    endif
                                                
                                       
         

            next temp
               
      if dixieblasted=true
         s=dixieblastedspeed
         select dixieblasteddirection
            case 1
               chary=chary-s
               scrollimage backdrop, 0, s/2
               scrollimage sky, 0, s/4
               scrolly=scrolly-s
               case 2
                  chary=chary+s
                  scrolly=scrolly+s
                  scrollimage backdrop, 0, -s/2
                  scrollimage sky, 0, -s/4
                  case 3
                     charx=charx-s
                     scrollx=scrollx-s
                     scrollimage backdrop, s/2, 0
                     scrollimage sky, s/4, 0
                     case 4
                        charx=charx+s
                        scrollx=scrollx+s
                        scrollimage backdrop, -s/2, 0
                        scrollimage sky, -s/4, 0
               endselect
               
               dixieblastedspeed=dixieblastedspeed-1
               
               if dixieblastedspeed<=0
                  dixieblasted=false
               endif
                  
                  
                  
               endif
                     
                        
      
      
      ;manage camera
      
      ;only in playmode
         if mode$="playmode"
      
            
            if scrollx+640-charx>320      ;left side
               scrollx=scrollx-4
            endif
            
            if scrolly+480-chary>240   ;top   side
               scrolly=scrolly-4
            endif
         
                  
            if chary-scrolly>240   ;right side
               scrolly=scrolly+4
            endif
               
            if charx-scrollx>320   ;left side.
               scrollx=scrollx+4
         endif
         
         
                     ;patch in barrel placing
                     
                        if rightmousebutton()
                              barrels(1).x1=mousex()+scrollx
                              barrels(1).y1=mousey()+scrolly
                              barrels(1).x2=barrels(1).x1+barrelwidth
                              barrels(1).y2=barrels(1).y1+barrelheight
                              
                              if spacekey()
                                 barrels(1).falling=true
                              endif
                                 
                              
                              
                           endif
                              
         
         
            
                  endif
         
                     
                        
                        if keystate(181)
                           mode$="tile_mode"
                        endif
                           
   
                     
                  
      
      
sync
cls rgb(0,0,0)
loop




function draw_blank_tiles()
for tempx=amountx to 20+amountx+1
   for tempy=amounty to 15+amounty+1
      
      x=(tempx-1)*32
      y=(tempy-1)*32
      
      xdraw=x-SCROLLX
      ydraw=y-SCROLLY

   
         
      
      ;tilenum=map(tempx, tempy)
      ;print "Tilenum is" +str$(tilenum)
      ;print "Press key to show image"
      ;waitkey
      ;waitnokey
      ;sync
         
         if tilenum=<0 then tilenum=1
         if tilenum=>101 then tilenum=100
         
      drawimage tiles(tilenum), xdraw, ydraw, 0
      
next tempy

      
         
               
               
   next tempx   
      rendertoscreen
drawimage timage, 0, 0, 0
endfunction

function pushbananaframe(number)
   
   bananas(number).frame=bananas(number).frame+1
   if bananas(number).frame>8 then bananas(number).frame=1
   
endfunction


[/pbcode]


TODO:
new flow chart for dkc2 engine

GUI changes

Tile placement

Collidable tiles

Scrolling

These are all fine
as soon as you click inside the tiles it should switch to tile placement.
not sure though hm..

We'll have objects window.

Objects: Solid blocks         CHECK/INPROGRESS
Sprites: Enemies
Objects: Tile hurt player      CHECK/INPROGRESS
Objects: Banana            CHECK/INPROGRESS
Objects: Coin
Objects: DKCOIN
Objects: Red/Green/Blue balloons
Objects: Target/finish
Objects: Start Location       CHECK/INPROGRESS
OBJECTS: Regular Barrel Grab/Throw/pickup/putdown CHECK/INPROGRESS
OBJECTS: Blast Barrel all direction   CHECK/INPROGRESS


List of enemies to add:
Zinger stationary          CHECK
Zinger flying foreward/up/down/paths    CHECK
Mosquitoes.
Necky
cannonball guy firing slow
cannonball guy firing fast
Sneak
BUG               CHECK


Two Screenshots

1:
Dixie about to jump into a blast barrel (still in debug mode)


2:
Beatles standing on platform with dixie and walking:

Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on February 22, 2012, 04:48:48 AM
So no new screenshots yet been busy with school and physical life.. and actual life stuff.
XD
But lots of planning.

Finally figured out a way to add some versatility to the game engine.
From now on once I update it, new sprites and whatnot will use framesheets for their animations.
They will have their own object.
I'll initiate 100 or so (however many special types there needs to be) for each character.. and parse a scripting file which
defines their type's attributes.
Which will make it easier for me to create new framesheets that are linked to objects.
Also.. every sprite in game will go through an object engine when I'm done creating it.
The object engine will process sprite events versus having them all hard coded.

in order for this to happen I need to code up an object event layer.
So as follows it will handle these things:

velocity
collision
input
scripts
sprite frames
sprite movement

Unfortunately for most of the engine, as it's already been built heavily up off the ground not everything can pass through the object engine.

I have to re code how collision checks work in order to link collision to the object engine.
Or do checks, during the collision checking loop of the game engine's core, and call the object engine to reference points.
This might save time in the long run since the collision check could not only speed up the checking of character objects against solid tiles.
But perhaps if the collision check routine was not called during the draw/update routine then it would speed up the draw/update routine.
Making the entire thing speed up.

I'm not sure how I'm going to link it all together since right now I've been using hybrid procedural and object oriented type techniques.
I'm going to re design some of how the game engine should work though now that I have a proto type to work with and draw logic from.

The goal in the end is to have more readable code, which is easier to maintain and more functional.

I think I've come a long way with my programming abilities and I do believe that this is why I am able to pursue such an undertaking now.

Things to look for if I do finish this will be an incredibly flexible game engine created in playbasic which handles and covers 2d hitbox based collision with basic physics and movement. Etc. framesheet loading/saving. scripts. and a few other tricks.
I have a long way to go on the design of this thing but it's getting there.
The next thing I might want to look into is actually setting up triggers for scripts, which allow multiple actions such as :

Beescript.txt->

:condition
PLAYERHIT
:actions
Playsound:Playerdie
PlayANIM Target: Player ANIM: Playerdie
ENDSCENE
MSG_ENGINE_MAIN(level_end)


A scripting language like that would be ideal for this type of game..
Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: micky4fun on May 18, 2012, 04:39:37 PM
Hi all

LemonWizard , this looks cool , looks quite involved , wish you luck with this game , keep the good work up
will keep an eye out for updates

mick :)
Title: Re: 2d sidescroller engine in progress: DKC2 remake. Test dev.
Post by: LemonWizard on June 08, 2012, 01:11:27 AM
I haven't had much time for forums, or programming because of math courses. Blareghh.

I am working on a few things, so this project is on the side at this time. Unfortunately.
HOWEVER I will be getting back to it quite quickly.. once summer starts. YAY summer.


There are a number of things that need improvement in the game engine itself and as I've posted before it needs re structuring or the project will be hard to maintain. I can't wait to continue working on this.