Code archives/Miscellaneous/RPG 2d scrolling game example
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
player, scrolling, multi maps, coins, doors,keys | |||||
AppTitle "RPG 2D scrolling multi map - cursor keys to move." Graphics 640,480,16,2 SetBuffer BackBuffer() Global editmode = False Global edittile Global keys = 0 Global gold = 0 ; map variables Global mw = 40 Global mh = 30 Global tw = 32 Global th = 32 Global numlevels = 5 Dim map(numlevels,mw,mh) ; player variables Global pw = (tw-5) Global ph = (th-5) Global px = GraphicsWidth()/2-tw/2 Global py = GraphicsHeight()/2-th/2 ; scrolling variables Global mx Global my Global msx=0 Global msy ; for the multi map ; ; this is a mdimensional array ; the player location on the multi map ; is mcx (map cursor x) ; it starts at 1,1, the center of the ; multidimensional array ; Global mcx=1 Global mcy=1 Dim ml(3,3) ;corner maps -1 non existant ml(0,0)=-1 ml(2,0)=-1 ml(0,2)=-1 ml(2,2)=-1 ; the maps assigned ml(1,0)=1 ml(1,1)=0 ml(2,1)=2 ml(1,2)=3 ml(0,1)=4 ; Here we create/buffer the maps Dim mapimage(5) For i=0 To 5 mapimage(i) = CreateImage(mw*tw,mh*th) Next Text 0,0,"Please wait" Flip readlevels() makemaps() .mainloop While KeyDown(1) = False Cls If KeyHit(18);key e If editmode=True Then editmode = False Else editmode = True EndIf edit If editmode = False For i=0 To 4 ;speed of movement moveplayer playeritemcollision centermap switchmap() Next DrawBlock mapimage(ml(mcx,mcy)),msx,msy drawplayer Color 255,255,255 Text 0,0,"Use cursors to move around" Text 0,15,"cursor : " + mcx +","+mcy+" on map : "+ml(mcx,mcy) Text 320,0,"gold:"+gold+" keys:"+keys Text 320,15,"Press e for edit mode" End If Flip Wend End Function edit() If editmode = True DrawBlock mapimage(ml(mcx,mcy)),msx,msy Color 20,20,20 Rect 0,0,GraphicsWidth(),36,True For x=0 To 10 drawtile(x,0,x) If edittile = x Color 255,0,0 Rect x*tw,y*th,32,32,False End If If RectsOverlap(MouseX(),MouseY(),1,1,x*tw,0,32,32) Color 255,255,255 Rect x*tw,0,32,32,False Color 0,0,0 Rect x*tw+1,1,30,30,False If MouseDown(1) = True edittile = x End If End If Next If RectsOverlap(MouseX(),MouseY(),1,1,0,32,GraphicsWidth(),GraphicsHeight()-32) x1 = (MouseX()-msx)/tw y1 = (MouseY()-msy)/th If MouseDown(1) = True map(ml(mcx,mcy),x1,y1)=edittile updatemap x1,y1,edittile End If Color 255,255,255 Rect x1*tw,y1*th,32,32,False Color 0,0,0 Rect x1*tw+1,y1*th+1,30,30,False End If If KeyDown(205) ; right msx=msx-3 EndIf If KeyDown(203);left msx=msx+3 End If If KeyDown(200);up msy=msy+3 End If If KeyDown(208);down msy=msy-3 End If End If End Function ; here we check if the player is ; at a border and if he can go to another map ; and set the start positions Function switchmap() ; touches the left side of the screen If px<5 And mcx>0 If ml(mcx-1,mcy) <>-1 mcx=mcx-1 px=630-pw msx=-(mw*tw-GraphicsWidth()) If py<10 Then py=py+10 If py+ph>GraphicsHeight()-10 Then py=py-10 End If End If ; touches the top part of the screen If py<5 And mcy>0 If ml(mcx,mcy-1) <> -1 mcy=mcy-1 py=470-ph msy=-(mh*th-GraphicsHeight()) If px<10 Then px=10 If px+pw>GraphicsWidth()-10 Then px=px-10 End If End If ; touches the right side of the screen If px+pw>GraphicsWidth()-4 And mcx<2 If ml(mcx+1,mcy) <> -1 mcx=mcx+1 px=10 msx=0 If py<10 Then py=10 If py+ph>GraphicsHeight()-10 Then py=py-10 End If End If ; touches the bottom of the screen If py+ph>GraphicsHeight()-5 And mcy<2 If ml(mcx,mcy+1) <>-1 mcy=mcy+1 py=10 msy=0 If px<10 Then px=px+10 If px+pw>GraphicsWidth()-10 Then px=px-10 End If End If End Function Function centermap() If px<GraphicsWidth()/3 And Abs(msx)>0 Then msx=msx+1 :px=px+1 If py<GraphicsHeight()/3 And Abs(msy)>0 Then msy=msy+1 :py=py+1 If px>GraphicsWidth()/100*66 If (Abs(msx)+GraphicsWidth()) < mw*tw msx=msx-1 px=px-1 End If End If If py>GraphicsHeight()/100*66 If (Abs(msy)+GraphicsHeight()) < mh*th msy=msy-1 py=py-1 End If End If End Function Function moveplayer() Local x=0 Local y=0 If KeyDown(200) ; up y=-1 End If If KeyDown(205) ; right x=1 End If If KeyDown(208) ; down y=1 End If If KeyDown(203) ; left x=-1 End If If px+x < 0 Then x=0 If px+pw+x > GraphicsWidth() Then x=0 If py+y < 0 Then y=0 If py+ph+y > GraphicsHeight() Then y=0 If playermapcollision((px+Abs(msx))+x,py+Abs(msy)) = False px=px+x End If If playermapcollision(px+Abs(msx),py+Abs(msy)+y) = False py=py+y End If End Function Function playermapcollision(x1,y1) Local cx=x1/tw Local cy=y1/th For y2=cy-1 To cy+1 For x2=cx-1 To cx+1 If x2>=0 And x2<=mw And y2>=0 And y2<=mh mt = map(ml(mcx,mcy),x2,y2) If mt >= 1 And mt <= 3 Or mt = 7 ; is the map around the player a block If RectsOverlap(x2*tw,y2*th,tw,th,x1,y1,pw,ph) ; ; Here the player is inside a wall ; a value 1 on the map ; Return True ; End If End If End If Next Next ; no collision occured Return False End Function Function playeritemcollision() Local cx=(px+Abs(msx))/tw Local cy=(py+Abs(msy))/th For y2=cy-1 To cy+1 For x2=cx-1 To cx+1 If x2>=0 And x2<=mw And y2>=0 And y2<=mh ; collision with coin If map(ml(mcx,mcy),x2,y2) = 9 ; is the map around the player a 9 value If RectsOverlap(x2*tw+8,y2*th+8,tw-16,th-16,px+Abs(msx),py+Abs(msy),pw,ph) ; ; Here the player touches a map item (9) ; We remove it from the map ; gold=gold+1 map(ml(mcx,mcy),x2,y2) = 0 updatemap(x2,y2,0) End If End If ; collision with key If map(ml(mcx,mcy),x2,y2) = 8 ; is the map around the player a 9 value If RectsOverlap(x2*tw+8,y2*th+8,tw-16,th-16,px+Abs(msx),py+Abs(msy),pw,ph) ; ; Here the player touches a map item (9) ; We remove it from the map ; keys=keys+1 map(ml(mcx,mcy),x2,y2) = 0 updatemap(x2,y2,0) End If End If ; collision with door If map(ml(mcx,mcy),x2,y2) = 7 ; is the map around the player a 9 value If RectsOverlap(x2*tw-1,y2*th-1,tw+2,th+2,px+Abs(msx),py+Abs(msy),pw,ph) If keys>0 ; ; Here the player touches a map item (9) ; We remove it from the map ; keys=keys-1 map(ml(mcx,mcy),x2,y2) = 0 updatemap(x2,y2,0) End If End If End If End If Next Next End Function Function updatemap(x,y,t) SetBuffer ImageBuffer(mapimage(ml(mcx,mcy))) drawtile(x,y,t) SetBuffer BackBuffer() End Function Function drawplayer() Color 0,0,255 Oval px,py,pw,ph End Function Function makemaps() For i=0 To numlevels SetBuffer ImageBuffer(mapimage(i)) For y=0 To mh-1 For x=0 To mw-1 a = map(i,x,y) drawtile(x,y,a) Next Next Next SetBuffer BackBuffer() End Function Function drawtile(x,y,t) Select t Case 0;nothing Color 0,0,0 Rect x*tw,y*th,tw,th Case 1;wall Color 255,255,255 Rect x*tw,y*th,tw,th,True Case 2;water Color 30,80,255 Rect x*tw,y*th,tw,th,True Case 3;tree Color 0,255,0 x1=x*tw y1=y*th Line x1+tw/2,y1,x1+tw,y1+th Line x1+tw,y1+th-1,x1,y1+th-1 Line x1,y1+th,x1+tw/2,y1 Case 7 ; door Color 150,150,150 Rect x*tw,y*th,tw,th Case 8; key Color 200,200,0 Oval x*tw+2,y*th+2,tw-4,th-4 Color 255,255,255 Text x*tw+tw/2,y*th+th/2,"K",1,1 Case 9 ; gold Color 200,200,0 Oval x*tw+2,y*th+2,tw-4,th-4 End Select End Function Function readlevels() Restore level1 For i=0 To numlevels-1 For y=0 To mh-1 For x=0 To mw-1 Read a map(i,x,y) = a Next Next Next End Function .level1 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1 Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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the doors. to fix this, make following change: Global pw = (tw-5) Global ph = (th-5) |
| ||
INCREDIBLE! :O Is there a way to add detection of a collision sprite on another map? I sometimes warp to another map & I'm stuck in a tree. A way to edit the Data of the levels would be INCREDIBLE! Keep up the GREAT work! ~GF |
| ||
@Dan - That bug I had before (last year or so) and I had a different fix but I forgot how I did that. @Guy - I might add a simple map editor. tonight Maybe I will add a warp key shortcut to. |
| ||
COOOOOOOOOOOOOOOOOOOOOL! =D Keep up the GREAT work! =) I see this project going a LONG way! ~GF |
| ||
@pakz i guess the bug is up to the steps which the circle need to move from one position to another. So if the circle is not 100% at the empty space, it wont go through. You can go through the door with your original example, you will need to use 2 keys (down/up and left if the door is at the left side). but if you try to position the circle directly at the door, and then press left, it doesnt work (here). so i made the circle a bit smaller. |
| ||
Any luck Pakz? =) ~GF |
| ||
I have not had any time yet Guy. Also, a map editor would require a save/load feature. Do you think you could do that on your own? Or should I just put in the code for you to enable? The code archives have no file inclusion. That is why I have the data statements in. |
| ||
Put the code in to enable would be awesome! =) Thanks Pakz! ~GF |
| ||
Pakz You can include ****small**** files (.zip, .png, .jpg) indirectly. http://www.blitzmax.com/codearcs/codearcs.php?code=3026 |
| ||
Thanks Andy :) @Dan - I changed the code, the player is now smaller. @Guy - I have added a simple editor. Press e for edit mode. Still need to add save and load feature. |
| ||
here's a blitzmax version with some error checking and deeper water added plus some minor interface changes |
| ||
Here's the same thing, translated into Blitz3D :: ~GF |
| ||
i guess drawline is blitzmax command ? |
| ||
Thanks, Dan. I edited it. If any of you don't like the way I code, you can shove it! =) That's the way it's going to stay! I like to turn my code into works of art! I'm not afraid to show it! There's something wrong with the Level Editor. For some reason when you go and select your Tile then try to delete something, a hard-to-see black square also shows up on the bottom left of the screen somewhere within the other sprites until the mouse button is let go of. There are a few weird collision glitches where the DARK BLUE water tiles have collision, & when warping on some areas of the Map, I get stuck in a tree & can't move... If the collision could be fixed, & a way to detect that there's a tile blocking the map, I would be eternally greatful! That would be AWESOME! Also, when moving North or South to the 2nd or 3rd map, the player jumps 10 tiles ahead when it should only be jumping one. Thank You! ~GF |
| ||
PATCH - V.0.3 ( Beta ) :: Small Fixes - Are as Follows : 1 ) Outlined the 'Information Panel' as opposed to using a black Rect so the user can more readily read the information at the top of the screen. 2 ) Added a timer-based-movement to the player as well as the program itself so it works on any Computer no matter what type of Graphics card. 3 ) Fixed the location of appearing on another Map once the border of a Map Teleports you to the next Map so the location is much closer to each 1st Tile when Teleporting. 2D_RPG.bb: ~GF |
| ||
Cool! |
| ||
@Pakz : There's something wrong with the Level Editor. For some reason when you go and select your Tile then try to delete something, a hard-to-see black square also shows up on the bottom left of the screen somewhere within the other sprites until the mouse button is let go of. There are a few weird collision glitches where the DARK BLUE water tiles have collision, & when warping on some areas of the Map, I get stuck in a tree & can't move... If the collision could be fixed, & a way to detect that there's a tile blocking the map, I would be eternally greatful! That would be AWESOME! Also, when moving North or South to the 2nd or 3rd map, the player jumps 10 tiles ahead when it should only be jumping one. And perhaps use of a HUGE spritesheet would be lovely too! That way we can start actually seeing a REAL game! =D Thank You! ~GF |
| ||
The original source (top one) is ok so isnt it? I checked the editor and it appears to work just fine. (I noticed the b3d version not having the draw background images being created) |
| ||
No, here's an image depicting the Level Editor problem :: ~GF |
| ||
This is the code that does what is depicted in the above even though after reading it & fixing it up a bit time after time, it functions nearly identical to the Blitzmax code. Which means the Blitzmax code is flawed. After 10 checks at least, I'm pretty sure I did everything right. 2D RPG {Patched}_V.0.3.bb: { SMALL EDIT } :: Fixed the Map Teleporting when Teleporting from the left of a Map to the right of a previous or next Map! Instead of 10 Tiles to the left, it only warps to 1 tile to the left. Which is correct! Edit is below : Thank You! ~GF |
| ||
Since the forum had an Internal Server Error when I tried to update my above post, I'm going to have to post it here til' this issue is resolved :: This is the code that does what is depicted in the above even though after reading it & fixing it up a bit time after time, it functions nearly identical to the Blitzmax code. Which means the Blitzmax code is flawed. After 10 checks at least, I'm pretty sure I did everything right. { SMALL EDIT } :: Fixed the Map Teleporting when Teleporting from the left of a Map to the right of a previous or next Map! Instead of 10 Tiles to the left, it only warps to 1 tile to the left. Which is correct! Also, that Red Tile should stand for Lava & kill the Player / game over / restart the game. It is currently not usable. =/ Edit is below : 2D RPG {Patched}_V.0.3.bb: Thanks! ~GF |
| ||
Here's a bit of Inspiration for our little RPG. I'm going to assume it's Zelda style because that would be just AWESOME to have an Open Source Legend of Zelda : Oracle Of Seasons - like Gameboy Advance game here on Blitz3D! =D The remix I found on Youtube & converted to OGG: Legend Of Zelda (8 Bit Remix).ogg : http://s000.tinyupload.com/download.php?file_id=84950797183698946747&t=8495079718369894674786652 And the Source : Legend_Of_Zelda_OOA_0.01_{Pre-Alpha}.bb: Enjoy! ^_^ Thanks! ~GF |
| ||
@guy I tried the last version. It gets really slow when you get to the lower part of the screen. I have not found the cause yet. It is on a laptop so this might not be noticable on a fast desktop. Might have to do with the entire sfreen beeing redrawn. Also in the save levels section you need to place a restore level1 line. Becourse there is a out of data error. |
| ||
@Pakz, here's a fix for the Save. It's working except it's crashing with out of data when I save on the 1st map, then go straight up to the 2nd map and try saving IT. I wanna be able to save to ALL level files on the fly, all at once. Code :: Thanks! ~GF |
| ||
What is wrong with this Save code, & why can't I get the left door on map 1 open like the other 2 doors on the right on map 1? Link to needed OGG Media : Zelda_ Link's Awakening Overworld Music (SNES Remix).ogg : https://mega.nz/#!6t8B3TAI!-wVdHvtEOVQXOxgmXEdTwdLnJnQD_q_f7AptbrKc1JI Oracle_Get_Rupee.ogg : https://mega.nz/#!Cp1wwIjI!A6Y9IgvudkuEP8_xC4eQ28QSA_fii2LLDmGOvpT6eqo Oracle_Get_Item.ogg : https://mega.nz/#!K1kV1Yia!0ZWZ4Pa162_1EyirhlTEeLJvGSIPAytsY-xUN6yaBQk Oracle_Chest.ogg : https://mega.nz/#!nwdRSCbI!2F8kLuMqmojCD8UG-uL_xQhT3h_X4s_xOPi5PDm8tio ------------------------------------------------------------ Legend_Of_Zelda_OOA_0.1_{Beta}.bb : Thanks! ~GF |
| ||
@Guy i'm on blitzmax, so my versions will be in that. Yep there are errors in the base edit code because of removing the bitmap draw code and going to drawing the entire map. that will also cause slowdown as you are drawing the entire map and not cheering for bounds. ok. I'll fix my version and post |
| ||
Sounds good! =) |
| ||
ok, this is still in progress. there is no map overview, loading saving not yet completed. There is a lot of extra drawing code - for all the new tile types (about 23). it works the same as before though. a lot of the internal code has been removed/changed to make it work correctly - proper error checking, etc added wall ignore mode - this is not the same as yours @Guy there is no sound - this is not needed for this the last graphic tile is a boulder - sort of desert pink/grey. it is a special case so there is some strange checking code just for it. basically you can push a boulder. if you push it into a hole - it fills it, if you push it into water, it drops into it. ok, all for now. here's the BlitzMax code : |
| ||
Adam, why is the last defdata in your code written as defeat ? |
| ||
This is INCREDIBLE, Adam! =) While I work on the translation for B3D, would you mind adding a sprite sheet loader so we can start decorating up the landscape? =) Thanks a ton guys! Look forward to seeing more updates! =) I'll keep you posted on my end as well! =) ~GF |
| ||
the defeat is really interesting as my source has got it as defdata. it might be the autocorrect as I copy it over - i'll keep an eye out for it :) |
| ||
ok, the code is too big, so i'm going to split it into 2 part 1: |
Code Archives Forum