UnderwareDESIGN

PlayBASIC => Show Case => Topic started by: LemonWizard on April 30, 2013, 07:38:44 PM

Title: Go Go Go! Demo. Playable.
Post by: LemonWizard on April 30, 2013, 07:38:44 PM
hey everyone, I know it's been a while since I've even had a post in here or something worth posting in here.
Life's been super busy. :D

I made something awesome today (well I think it's awesome) and I'm going to share it with you.
It's going to be a multiplayer game sometime soon.
So it's going to use MultiSync later.

For now it's single player demo.
Here's screenshots for you, and a working demo as an attachment.
The code is posted below to.

[pbcode]
; PROJECT : Go_Go_Go
; AUTHOR  : LemonWizard
; CREATED : 4/30/2013
; EDITED  : 4/30/2013
; ---------------------------------------------------------------------


//This project is a test project and not yet complete yet
//All of the art and code in this project are mine.
//you may not re use any of the resources included within this project without my personal consent
//if you wish to help me with this project you can email me or pm me on the forums.

// EMAIL ADDRESSES REMOVE- DOWNLOAD ATTACHMENT FOR FULL CODE
         
               ///Thank you all and enjoy this simple but fun demo!
               


camera=off



openscreen 1024, 768, 32, 1
amountofsolidsx=getscreenwidth()/16
amountofsolidsy=getscreenheight()/16


//use space key at start of menu screen to actually start
//you can use the enter key in order to change camera modes, currently can not be changed back.
//you can use the right mouse button to reposition your character if it falls.

         

dim solids(amountofsolidsx, amountofsolidsy)
#include "multisync"
titlescreen "Go Go Go! (Development Mode)"

//check for tile data here

if fileexist("/collision_data.txt")
   readfile "/collision_data.txt", 2
   
   for tempx=1 to amountofsolidsx
      for tempy=1 to amountofsolidsy
         solids(tempx, tempy)=readint(2)
      next tempy
   next tempx
            closefile 2 //we want to close it now
            
endif  //only try to load tile data if file exists

screen1=loadnewfximage("Thatartthere.png")
cursor=loadnewfximage("cursor.png")
menu=loadnewfximage("menu.png")
character1=loadnewfximage("character_1.png")
multistage=loadnewfximage("Multi_level1.png")


imagemaskcolour cursor, rgb(255, 255, 255)
imagemaskcolour character1, rgb(255, 255, 255)

cursory=330
cursorx=115


character=newsprite(0, 0, character1)
autocenterspritehandle character, true

spritedrawmode character, 02


mainmenu:



drawimage screen1, 0, 0, 0

drawimage menu, 100, 300, 0

drawimage cursor, cursorx, cursory+cursor, 1

if downkey()
   cursory=cursory+16
endif

if cursory>420 then cursory=420

if upkey()
   cursory=cursory-16
endif

if cursory<330 then cursory=330
   

sync
cls rgb(0,0,0)

if spacekey()
   char1falling=true
   stage_screen=newfximage(1024, 768)
   camimage=newfximage(400, 400)
   screenimage=newfximage(400, 400)
   goto multiplaydemo
      
endif
   

goto mainmenu



multiplaydemo:

               if camera=on
         rendertoimage stage_screen
         endif
            

      char1falling=true //set the falling value to true before we do any checking
      


drawimage multistage, 0, 0, 0


//drawimage character1, char1x, char1y, 1

rotatesprite character, 360-char1jumptime

positionsprite character, char1x+82/2, char1y+85/2

drawallsprites


if leftmousebutton()
   
for tempx=1 to amountofsolidsx
   for tempy=1 to amountofsolidsy
      
      select solids(tempx, tempy)
         case 1
      box (tempx-1)*16, (tempy-1)*16, tempx*16, tempy*16, 0
         case 2
            box (tempx-1)*16, (tempy-1)*16, tempx*16, tempy*16, 1
         endselect
            
         
         if mouseinbox((tempx-1)*16, (tempy-1)*16, tempx*16, tempy*16)
            solids(tempx, tempy)=1
         endif
            
         
            
   next tempy
next tempx

endif


for tempx=1 to amountofsolidsx
   for tempy=1 to amountofsolidsy
      
      x1=(tempx-1)*16
      y1=(tempy-1)*16
      x2=tempx*16
      y2=tempy*16
      
            ///test for a collision on solid ground that is "known"
            
                  //yay
                  ///later implement an AI to play the game
                  
                  
                     //if not jumping
                        if char1jumping=false
                           
                  if solids(tempx, tempy)=1
                     
                     testingy1=char1y+75
                        
            if char1x+40=>x1
               if char1x+40<=x1+16
                  if testingy1=>y1
                     if testingy1<=y1+16
                        char1falling=false
                     
                           
                        print "OH A COLLISION!!!!"
                        titlescreen "COLLISION HAPPENED"
                  endif
               endif   
            endif
            endif
                        
                              
                  
                  
                  //box x1, x1+16, y1, char1y+16, 1            
                              
                  
               
               
                     endif
                                 ///and we only check if the character is jumping first to that way he cant fall while jumping somehow   
                        endif ///only do this for a solid block!
                        
                     //hopefully I have those value right NOW TEST
                  next tempy
               next tempx
                        
                                 
         
         
         
         if rightmousebutton()
            char1x=mousex()
            char1y=mousey()
         endif
                        
                        
//make sure we only do this after we've seen if tiles have collided or not
if char1falling=true
   char1y=char1y+7
endif

if spacekey()
if char1jumping=false
   if char1falling=false   
   char1jumping=true
   char1jumptime=25
endif
endif

endif


if char1jumping=true
   char1falling=false
   char1jumptime=char1jumptime-1
   
   char1y=char1y-char1jumptime
endif
         

if char1falling=true
   if char1y>200
      char1falling=false
   endif
endif
      
      if char1jumping=true
         if char1jumptime<1
            char1jumping=false
            char1falling=true
         endif
      endif
            
            
            if leftkey()
               char1x=char1x-5
                  
            endif
            
            if rightkey()
               char1x=char1x+5
            endif
                  

camera_x1=char1x-200
camera_y1=char1y-200
camera_x2=char1x+200
camera_y2=char1y+200


if camera_x1<1 then camera_x1=1
if camera_y1<1 then camera_y1=1

if camera=on

getimage camimage, camera_x1, camera_y1, camera_x2, camera_y2

draw_camerasees(camimage)

endif


if enterkey()
   camera=on
   savefile$="/collision_data.txt"
   writefile savefile$, 1
   
   for tempx=1 to amountofsolidsx
      for tempy=1 to amountofsolidsy
         
         writeint 1, solids(tempx, tempy)
      next tempy
   next tempx
            closefile 1
   ///save the collision data for later once we change camera modes      
   
endif
   

sync
cls rgb(0,0,0)


goto multiplaydemo


function draw_camerasees(camimage)
   
   rendertoscreen
   scaleimage camimage, 1024, 768, 1
   
   drawimage camimage, 0, 0, 0

endfunction
[/pbcode]


By the way an update! URGENT UPDATE: The collision data did not transfer in the upload.
If you want to try out the platforms thing, you have to place the solid blocks yourself. You can do this by using the left mouse button anywhere on the screen. It's pretty simple. :D



Mod Edit: Contact details remove the code block, download the attachment for those.

Title: Re: Go Go Go! Demo. Playable.
Post by: BlinkOk on May 01, 2013, 12:22:17 AM
it's a good start lemony dude.
my dude kept falling off even though i had placed tiles there. it seems whenever the tiles are placed to make a hill going up hell fall off.
btw: you right click to drop the player dude (just so people know)
Title: Re: Go Go Go! Demo. Playable.
Post by: LemonWizard on May 01, 2013, 02:23:12 AM
Thanks BlinkOK :D

In case no one read the comments in the code, once you'ved placed your collision tiles.
You can actually hit the enter key to get a zoomed camera effect.
It slows it down a bit, I don't know how to speed that up. To a playable... speed.
Maybe kevin would like to help with that one? :)I wanted to do something similiar to how the camera
in smash bros works.