Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : PI*Bert Game engine ?
Page 1 of 2 | |||||
Author | Message | ||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1114 |
Hi, I started to design a Q*Bert-like game for the Pico. Unfortunately, I don't have the time, at the moment, and patience to create a finished game out of it . I have already designed the pyramids for 8 levels of 4 rounds and all the sprites. I would be happy if someone here could finish programming this. Does anyone dare to do that for PicomiteVGA and/or LCD (Tomboy)? Cheers Mart!n MODE 2 'Init all Dim integer f,n,oc,wx,wy,l,r,obj(10,10) 'moving Object Vars '1 Bert, 2 RBall, 3 GBall, 4 Coily, '5 WrongWay,6 Ugg, 7 Slick 8 Sam, 9 Disc Dim cl%(15):Restore colors:For f=1 To 15:Read cl%(f):Next Dim sw%(8)=(0,3,5,6,7,5,4,2,0),sp$ FRAMEBUFFER layer FRAMEBUFFER write l CLS cl%(5) FRAMEBUFFER write n Restore qb1 For n=1 To 26 Read wx,wy For y=0 To wy-1 Read sp$:sp$=expand$(sp$) For x=0 To wx-1 Pixel x,y,cl%(Val("&H"+Mid$(sp$,x+1,1))) Next x Next y Sprite read n,0,0,wx,wy:Box 0,0,wx,wy,,0,0 Next n FRAMEBUFFER write l:CLS FRAMEBUFFER write n Dim LC%(8,4,5) Restore Levels For l=1 To 8:For r=1 To 4 Read l1$ For n%=1 To 5:LC%(L,R,n%)=Cl%(Val("&H"+Mid$(l1$,n%,1))):Next Next :Next '---------------------------------------------- 'demo Do pyra LC%(1,1,1),LC%(1,1,2),LC%(1,1,3) FRAMEBUFFER write l:CLS :Text 0,0,"DEMO" For m=1 To 3 qx%=10:qy%=196 For n=1 To 7 jump 1 Pause 300 Next Box 120,28,16,16,,0,0 Next FRAMEBUFFER write n For l=1 To 8:For r=1 To 4 Text 256,0,"Level="+Str$(l) Text 256,16,"Round="+Str$(r) pyra LC%(L,R,1),LC%(L,R,2),LC%(L,R,3) Pause 500 Next : Next For l=1 To 15:fields cl%(l):Pause 250:Next x=0:y=0 FRAMEBUFFER write l For n=1 To 26 Sprite write n,x,y Sprite write n,x+160,y,1 Inc x,24:If x>=150 Then x=0:Inc y,32 Next Pause 20000 FRAMEBUFFER write n CLS Loop 'end demo '------------------------------------------------ ' 'Interrupt would be called every 40 ms... main Game loop here (to come) Sub Mainloop Local f For f=1 To 10 'object in this Level/Round? If Not obj(f,9) Then move_on 'object active? If Not obj(f,0) Then move_on 'code etc. move_on: Next End Sub Function expand$(pxl$) Local n%,nmb%,tmp$,co$ n%=1: Do If Asc(Mid$(pxl$,n%,1))< 71 Then tmp$=tmp$+Mid$(pxl$,n%,1) Else co$=Hex$(Asc(Mid$(pxl$,n%,1))-71) Inc n%:nmb%=Val("&H"+Mid$(pxl$,n%,1)) tmp$=tmp$+String$(nmb%+1,co$) EndIf Inc n%:Loop Until n%>Len(pxl$) expand$=tmp$ End Function '---------- Sub jump(dir%) 'For Demo .. has to be included in Main Local x%,ox%,oy%,of% FRAMEBUFFER write l ox%=QX%:oy%=QY% Select Case dir% Case 1 For x%=qx% To qx%+15 Step 2 'If of%=1 Then Sprite hide 1 Box x%-2,oy%,16,16,,0,0 Inc qy%,-3 Sprite show 2-(of%=7), x%, qy%-sw%(of%), 2,1 oy%=qy%-sw%(of%) Inc of% Pause 40 Next Inc qx%,16 End Select End Sub ' 'Draws the playground in colors 1 (top) 2 (left) and 3 (right) Sub pyra C1%,c2%,c3% tx%=112 For y=0 To 6 For n=0 To y:field tx%+32*n,32+24*y,c1%:block tx%+32*n,40+24*y,c2%,c3%:Next Inc tx%,-16 Next End Sub '------- to recolor just the Top Sub Fields c1% tx%=112 For y=0 To 6 For n=0 To y:field tx%+32*n,32+24*y,c1%:Next Inc tx%,-16 Next End Sub '------------- Sub field x,y,c Triangle x,y+8,x+16,y,x+16,y+16,c,c Triangle x+32,y+8,x+16,y,x+16,y+16,c,c End Sub Sub Block x,y,c1,c2 'left Triangle x,y,x+16,y+8,x,y+16,c1,c1 Triangle x,y+16,x+16,y+8,x+16,y+24,c1,c1 'right Triangle x+17,y+8,x+32,y,x+32,y+16,c2,c2 Triangle x+17,y+8,x+17,y+24,x+32,y+16,c2,c2 End Sub colors: Data RGB(BLUE),RGB(GREEN),RGB(CYAN),RGB(RED) Data RGB(MAGENTA),RGB(YELLOW),RGB(WHITE),RGB(MYRTLE) Data RGB(COBALT) ,RGB(MIDGREEN),RGB(CERULEAN),RGB(RUST) Data RGB(FUCHSIA),RGB(BROWN),RGB(LILAC) 'levelcolors 'colors per round:Top, left, right,transition,target Levels: Data "93806","68E09","7280A","B3106" Data "98E62","431B6","E3896","6009E" Data "36C09","BA807","98E07","6A809" Data "ACE69","90046","6A84B","531B6" Data "E3869","28E96","8A8B7","6A1B4" Data "28E96","B3146","E3869","E0096" Data "96C35","7A88B","28E96","6389E" Data "98E62","E0096","6389E","6A1B4" field: Data 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,1,0,1,0,0,0,0,0,0 Data 0,0,0,0,0,1,0,1,0,1,0,0,0,0,0 Data 0,0,0,0,1,0,1,0,1,0,1,0,0,0,0 Data 0,0,0,1,0,1,0,1,0,1,0,1,0,0,0 Data 0,0,1,0,1,0,1,0,1,0,1,0,1,0,0 Data 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0 'Compressed sprite Data 'always facing left, have to be mirrored when looking to the right '2nd sprite is the Object jumping '1 Bert (4 Sprites) qb1: Data 16,16 Data "GF","GF" Data "0CCEG3CCEEG3","4CCEE0K2CCEEG2","4S2EE774CCU200","04S3874S2EE00" Data "004S2874S2U20","G24CC44C4S2EE0","G344C4S4EE0","G3K2S5EE0","G344CC4S400" Data "G4K2CC4CCG2","G5K2S2G3","G4K204CG4","G2440C4C44CG3","G4K20044CG2""" Data 16,16 Data "0CCEG3CCEEG3","4CCEE0K2CCEEG2","4S2EE874CCU200","04S3874S2EE00" Data "004S2774S2U20","G24CC44C4S2EE0","G344C4S4EE0","G3K2S5EE0","G344CC4S400" Data "G4K2CC4CCG2","G5K2S2G3","G6400CG4","G54400CG4","G24C004S2G4" Data "G344C4044CG3","G544G24CG2" Data 16,16 Data "GF","GF","G7S3G3","G5K4S200","G5884884C440","G5874874CC44","G4EK5CK2" Data "G2EES344S244","00ES9K2","0ECCK2C4C4C4C44","0C8844044CK40","04884G2K500" Data "0044G3K4G2","G74004G3","G5CC400S200","G3EC400EEC4G2" Data 16,16 Data "G7S3G3","G5K4S200","G5774774C440","G5884884CC40","G4E884884CK2" Data "G2EES344S244","00ES9K2","0ECCK2C4C4C4C44","0C8844044CK40","04884G2K500" Data "0044G3K4G2","G74G24G2","G74G24G2","G74G24G2","G5CC400S200","G3EC400EEC4G2" 'BALL red (2 Sprites) Data 16,12 Data "GF","GF","GF","GF","G5K4G4","G3K8G2","G2K27K600","00K27K80","00K88K20" Data "00K78K30","G2KA00","G4K6G3" ' Data 16,12 Data "GF","GF","G5K4G4","G3K8G2","G2K27K600","00K27K80","00KC0","00K98440" Data "00K88K20","G2K588K200","G3K8G2","G5K4G4" 'Ball GREEN (2 Sprites) Data 16,12 Data "GF","GF","GF","GF","GF","GF","G5Q3G5","G3Q7G3","G2Q27Q32AG2" Data "G2AA7Q42AG2","G2Q62AAG2","G3Q7G3" ' Data 16,12 Data "GF","GF","GF","GF","G5Q3G5","G3Q7G3","G2Q27Q5G2","G2AA7Q42AG2" Data "G2Q72AG2","G2Q522AAG2","G3Q222Q2G3","G5Q3G5" 'MBall Coily Drop (2 Sprites) Data 16,16 Data "GF","GF","GF","G4L5G4","G2L2V3L2G2","0055F7L700","055F77L80","055F77L80" Data "55FLC","LB8585","LA85885","0L7O400","00L4885O2G2","G3L488G4","GF","GF" ' Data 16,16 Data "G4L5G4","G2L9G2","00L3V3L300","0L2F7L80","L2F77L9","55FLC","LB8585" Data "LB8585","LA85885","L8O55","0L5885O350","00L6O3500","G2L2O455G2","G4L5G4" Data "GF","GF" 'Coily 16x32 up (2 Sprites) Data 16,32 Data "GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF" Data "GF","00FF0V3G6","0FL7G5","0FL8G4","0FL9G3","FLAG3","FL2G4L2G3" Data "07005500L3G3","0FL8G4","00FL7G4","00L6G6","00F5G65G3","00F55G355G4" Data "G2FL605G2","G3FL30055G2","GB5G2","GF" ' Data 16,32 Data "00FF0FFG8","0FL5G7","0FL5V2G4","0FL8FG3","FLAG3","FL4G3L2G2","055G7L200" Data "07007G65500","GBF550","G35V2G3F550","00FL5F00F550","0FL200L2005500" Data "L3FG2L30500","FL2FG3L3G2","0FL2V250L2G2","00FL6055G2","G4L300L200" Data "GB5500","GBF550","00V6G2F550","0FL700F550","0FL2G2L20L20","0F55G3FL20500" Data "0FL50L3G2","G45500L3G2","G9L2G2","G9L2G2","G9L2G2","G2FG5L2G2" Data "G25FG3F55G3","G355V255G4","G555G7" 'Coily 16x32 down (2 Sprites) Data 16,32 Data "GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF" Data "GF","00FF0FF5FG6","0V555FG5","078787L3FG4","05N2L5FG3","L70L2FG2" Data "L6G255FG2","0L4G355FG2","07007G2L3G3","G2L70FG2","G3L4005FG2","G8F55FG2" Data "G25G3FL2G3","G35V3L2FG2","G5L405F00","GB5F00","GB5G2" ' Data 16,32 Data "00FF0FFG8","0V55G7","07878755V2G4","05N2L5FG3","LBFF00","L5G3L2F00" Data "0L4G4L2F0","07007G655F0","GC55F","G35V2G455F","00L6FG255F","0L300L2FL2F0" Data "L3FG4L3F0","0505FG3L3F00","00505V2L4G2","G250L500F00","G4L2G355F0" Data "GB55F0","GC55F","005V5G355F","0L7FG255F","0L3G35FL3F","0L2G5L3F0" Data "0LBF00","G4L4G5","GAV200","G9L2F00","G9L2F00","G2FG5L300","G25FG3FL2G2" Data "G355V255G4","G555G7" ' WrongWay (2 Sprites) Data 16,16 Data "GF","00L2G45G4","0FFG655G3","F00F005500505G2","F500L600500","0FL805G2" Data "00F5878755005500","0FF558787L3050","FF57755785005005","0FN3557G6" Data "FF7788755G6","FFN28755V25500","FF5N288700FG3","0FF55778700FFG2","V477G8" Data "00V2GA" ' Data 16,16 Data "00L2G45G4","V25G65G3","FF0FFG4505500","FG455055G250","FF00L5G2500" Data "0FL6G2L20","00L27L3055055","0FL37L4G25","V2775575FFG4","0FN3557G6" Data "FFN4L2G5","FF7887755F5G4","FF57O2770FL200","0FF55787G2FG3","V477G4F500" Data "00V2GA" '6 Ugg (2 Sprites) Data 16,16 Data "G57G8","G3705G8","00700F5G8","G250F550FF00550","G250F05FF500550" Data "00F500F55F550505","00F55FF5F578L3","00F0L2F57885500","G3L378875G2" Data "00FFL387L300","0L978500","50L6F775G2","500L5F7FF500","0500L4V20L2" Data "0050050L4G3","GAL200" ' Data 16,16 Data "G47G9","G2705G9","0700F5G9","0050FL20FF00550","7050F005FF500550" Data "0F5G2FL40585","0FL2FF55F58L3","0F00L3F58L200","G3L2F58L2G2","00FFL900" Data "0L977500","50L6F775G2","500L5F8FF500","0500L4V20L2","0050050L4G3","GAL200" '7 Slick (2 Sprites) Data 16,16 Data "GF","GF","G9EG4","G6E0E00EG2","G5U30EG3","G4EEAEAEG4","G3EAEEAEAEG3" Data "G27AA7Q2E2G3","G278787AA2A2G2","00A78787A2A22G2","00AN42A22AG2" Data "00A72272AI3G2","00I7A2G3","G228822AI2G3","G3I6G4","G2I20I2G5" ' Data 16,16 Data "G6E0E00EG2","G5U30EG3","G4EEAEAEG4","G3EAEEAEAEG3","G27AA7Q32G3" Data "G277878AA2A2G2","00A77878A2A2AG2","00AN42AI2G2","00A72272A22A2G2" Data "002288I5G3","G2288I2A22G3","G3I7G3","G42G222G4","G42G22G5","G42G22G5" Data "G3I20I2G4" '8 Sam (2 Sprites) Data 16,16 Data "GF","GF","G9EG4","G6E0E00EG2","G5U5G3","G4U3AE00E00","G3EAEAAEAEEG2" Data "G2Q72G3","G287887O4G2","00A87887A2A22G2","002882882AI2G2","00I5AI3G2" Data "00I9G3","G2288I4G4","G3I6G4","G2I20I2G5" ' Data 16,16 Data "G6E0E00EG2","G5U30EG3","G5EAEAE00E00","G3EEAEAEAEEG2","G2Q6E2G3","G2O8G3" Data "00A87887A2A22G2","002872872AI2G2","00I5AI3G2","00I9G3","G2288I5G3" Data "G2I7G4","G322G222G4","G42G22G5","G42G22G5","G2I20I2G5" '9 Disc (4 Sprites) Data 16,12 Data "GF","G54499G5","G2K6P2G2","0K8P40","K2I34P66","4I66P3M2","3I4M88" Data "J2I2M6O2","0J4226683O20","G2J483838G2","G53383G5","GF" ' Data 16,12 Data "GF","G52244G5","G2I6K2G2","0I8K40","I2M32K69","2M69K3P2","3M4P88" Data "J2M2P6O2","0J4669983O20","G2J483838G2","G53383G5","GF" ' Data 16,12 Data "GF","G56622G5","G2M6I2G2","0M8I40","M2P36I64","6P64I3K2","3P4K88" Data "J2P2K6O2","0J4994483O20","G2J483838G2","G53383G5","GF" ' Data 16,12 Data "GF","G59966G5","G2P6M2G2","0P8M40","P2K39M62","9K62M3I2","3K4I88" Data "J2K2I6O2","0J4442283O20","G2J483838G2","G53383G5","GF" ' end Edited 2023-08-21 17:09 by Martin H. 'no comment |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4043 |
That's a shame Martin, but I know what it's like to be short of time. I've taken a bookmark, but I doubt I will do anything with it myself. Now "probably" the Game*Mite, release coming at the beginning of September ... I hope. Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4246 |
Hi Martin, I have never played the game. I have no idea what to do with the marveous sprites you created. Maybe Vegipete can pick this up ? Volhout PicomiteVGA PETSCII ROBOTS |
||||
lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3150 |
Running on standard PicoMite with 480x320 ILI9488 LCD after replacing "SPRITE" with "BLIT". Commenting out the first line, "MODE 2" it ran to line 114: blit show 2-(of%=7), x%, qy%-sw%(of%), 2,1 I commented that out and it ran to Level 8, Round 4, flashing many colors in a triangle of apparent cubes of which you can see three sides (which appear to be the same shape in different orientations). It crashed at line 59, Blit write n,x+160,y,1 This is what a screen shot looks like after the crash: I commented out line 59 and then it runs to the same point, Level 8, Round 4, and then, after a pause, it repeats. (I have no idea what might happen if those lines were not commented out, and know nothing about the game.) PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1114 |
That's the difference between Sprite and Blit Sprite write n,x+160,y,1 works on Picomite VGA, the ",1" tells the Pico to show the Sprite mirrored. Sadly this option doesn't work with Blit.. So you can delete the last parameter, but the Sprites are always facing left. Of course, you can also create them in both directions, something like Restore qb1 For n=1 To 26 Read wx,wy For y=0 To wy-1 Read sp$:sp$=expand$(sp$) For x=0 To wx-1 Pixel x,y,cl%(Val("&H"+Mid$(sp$,x+1,1))) Pixel (2*wx)-x,y,cl%(Val("&H"+Mid$(sp$,x+1,1))) Next x Next y Next n That doubles the number of Sprites and you will run out of possible Sprites, So for the game you leave most of the sprites untouched, but Bert and Coily have to be mirrored (for the movement right up and right down) and that would be 8 additional sprites. Edited 2023-08-21 23:07 by Martin H. 'no comment |
||||
lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3150 |
Ah, thanks. I wouldn't have remembered it, but in playing with the new F4 release, I discovered that I had asked about adding the mirror option to BLIT WRITE back in April of 2021: "(Note--VegiPete used the CMM2's mirroring parameter to flip the walking man and pushing man--I had to reverse the pixels on the bmp image screen and save walking left and pushing left and right. It would be useful to save memory on the F4 by providing that mirroring parameter to BLIT WRITE.)" PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1611 |
Yes, if the orientation parameter could possibly be added to the PicoMite also, it would also save many sprites for Martins Q*Bert program running on the PicoMite using LCD screens. Bill Keep safe. Live long and prosper. |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4246 |
Martin, I have read up a bit on WIKI how this game is played, and I think the core could be implemented as follows (you have done the sprites, and demo'ed movements, but the game core is missing). I think you need 2 arrays "old" and "new" (9x9) that are 45 degrees CC rotated from the actual playing field. Each cell contians a value. 0=empty, 1=Q*bert, 2=Curly, 4=UGG etc...The (0,0) location is the location above the top of the piramid. Sprites (except the discs) die when they meet (X=0) or (Y=0) or (X+Y>8). The discs move along X=0 axis or Y=0 axis, and carry Q*bert to the top. These arrays contain the "static" status after move. Each time the static phase is entered, new() is copied to old(), and a new new is calculated. Between static states, all sprites move in X steps from position old to position new. The move state is blocking. During this state only music can be heard. A "move" could take 8 steps of 40ms = 320ms, allowing you to maximum move any sprite 3 cubes per second. In the static state between moves, keyboard is handled, and collisions are detected, Curly get's new directions calculated from it's position. And sprites are removed when dead. The whole gameplay takes place in the 45 degrees rotated matrices, only the movement phase translates array coordinates to screen coordiates. DO static phase 'update gameplay movement phase 'fixed time, doing X sprite micro-movements for all active sprites LOOP If you can get the "static phase" executed in 40ms then the sprites would move extremely fluent at 25 frames per second (assuming 40ms in each of the X sprite moves). Again, I have no idea how the game is played, but this is the basis I would start out with. Volhout Edited 2023-08-22 18:12 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1114 |
Hi Volhout For the Gameplay all Sprites should be able to move at the same time. As I imagine it... to see them jumping, the Movement of an Object from A to B has to be splitted into serveral 8 Steps. It is not a stikt moving from xo,yo to xn to yn For that I substracted an Offset from the y Position to simulate the Jump Dim sw%(8)=(0,3,5,6,7,5,4,2,0) The interrupt driven Movement loop has to look after every possible Object.. Is it aktive in Game?, is it moving?, if so, which state of the moving is it in? etc .. Delete the Sprite at the old position and redraw it on the new position, store the new position etc in the Array "obj(nr,value)" and continue with the next object... To look after the Coordinates i planed to use the Data after the field: lable As you assumed should this be in an array. JSo here, the Top of the Pyramid is 0,7.. but you can also use the 45 degrees rotated matrices Edited 2023-08-22 19:27 by Martin H. 'no comment |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4246 |
Yeah, I noticed that. And this "jump" movement could even be different fo Curly, who is "sliding" more than jumping ? What I tried to explain in previous post is that I wanted to avoid using interrupts. Simply a fixed loop that runs roughly 3x per second. in this loop you skip what does not need to be updated (sprites that are not active). I have become averse from interrupts by the huge amount of time spend on MAXITREK. With the omni-potent interrupts it became a nightmare to debug. I am not ready to dream another nightmare. A loop is deterministic. And the only interrupt I would suggest is the sound interrupt. Volhout PicomiteVGA PETSCII ROBOTS |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1114 |
that array could be individual for every object in Game (if needed) yeah, thats a mess ... If one call takes longer than the Interrupt Timeframe you are in trouble. For Test, I usualy call this sub 1000 times and mesure the Time it takes.. If it takes longer, I try zu optimise the Code that it fits into the interval. Other option is to speed up the Pico or use less Interrupts / Second. 2nd Issue, if working with sprites in Tick sub could be, that you never know in what Layer/Framebuffer you are at the Moment. You have to take care that you allways on the right screen. In this example, try to flip the top Color on the Pyramid while the Sprites are moving.. Your Main program switches to N (the normal screen) but the Sprites are using the Layer, so while you just start to draw the Top Color the Interrupt Sprite routine can switch back to layer ... and so on. Therefore, and as there is not much happening on the N Screen, it would be helpful to Pause the Interrupt while painting or writing to N. Edited 2023-08-23 16:48 by Martin H. 'no comment |
||||
lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3150 |
On a picomite with ILI9488 480x320 LCD, here's a screen shot of the sprites in normal orientation and flipped with Peter's new code for BLIT WRITE which allows mirroring: After the sprites are read in and built: For n=1 To 26: Blit write n,n*18,80: Blit write n,n*18,160,1: Blit write n,n*18,240,2:Next ~ Edited 2023-08-28 01:41 by lizby PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1114 |
That's how they're supposed to look. Unfortunately I can't get my "LCD Pico" to display anything at the moment. I will test it. But that all has to wait, from Tuesday I'll be in the Netherlands for 8 days. My first vacation after 5 years.. Cheers, Mart!n Edited 2023-08-28 05:11 by Martin H. 'no comment |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1109 |
Use "ax" and "ml" keys to make Q*Bert jump around on his pyramid. Or into space around his pyramid, because there is no bounds checking yet. PicoMiteVGA Beta 5.07.08.12 autosave OPTION DEFAULT INTEGER MODE 2 'Init all ' Character movement directions const d_UL = 0 ' Up Left const d_UR = 1 ' Up Right const d_DL = 2 ' Down Left const d_DR = 3 ' Down Right Dim integer f,n,oc,wx,wy,l,r,obj(10,10) 'moving Object Vars '1 Bert, 2 RBall, 3 GBall, 4 Coily, '5 WrongWay,6 Ugg, 7 Slick 8 Sam, 9 Disc Dim cl(15):cl(0)=0:Restore colr:For f=1 To 15:Read cl(f):Next Dim sw(8)=(0,3,5,6,7,5,4,2,0) Dim sp$ FRAMEBUFFER Create ' create buffer to invisibly generate sprites FRAMEBUFFER Write F ' make active Restore qb1 For n=1 To 26 Read wx,wy For y=0 To wy-1 Read sp$:sp$=expand$(sp$) For x=0 To wx-1 Pixel x,y,cl(Val("&H"+Mid$(sp$,x+1,1))) Next x Next y Sprite read n,0,0,wx,wy:Box 0,0,wx,wy,,0,0 ' reads from active FRAMEBUFFER Next n FRAMEBUFFER Layer ' create buffer for actor overlay FRAMEBUFFER Write L:CLS FRAMEBUFFER Write N ' make background layer active Dim LC(8,4,5) Restore Levels For l=1 To 8 For r=1 To 4 Read l1$ For n=1 To 5 LC(L,R,n)=Cl(Val("&H"+Mid$(l1$,n,1))) Next Next Next '---------------------------------------------- 'demo FRAMEBUFFER Write N ' draw on background pyra LC(1,1,1),LC(1,1,2),LC(1,1,3) Text 0,0,"DEMO" FRAMEBUFFER Write F ' draw on invisible buffer CLS qb_x=122:qb_y=28 ' start at top Sprite write 3, qb_x, qb_y-1, 1 ' draw initial QBert FRAMEBUFFER COPY F, L, B ' show 'im Do k2 = 0 do k1 = k2 k2 = asc(inkey$) loop until (k1 <> 0) and (k2 = 0) select case k1 case 97 ' a = Up Left Qjump d_UL case 108 ' l = Up Right Qjump d_UR case 109 ' m = Down Left Qjump d_DL case 120 ' x = Down Right Qjump d_DR end select Loop 'end demo '------------------------------------------------ ' 'Interrupt would be called every 40 ms... main Game loop here (to come) Sub Mainloop Local f For f=1 To 10 'object in this Level/Round? If Not obj(f,9) Then move_on 'object active? If Not obj(f,0) Then move_on 'code etc. move_on: Next End Sub Function expand$(pxl$) Local n,nmb,tmp$,co$ n=1: Do If Asc(Mid$(pxl$,n,1))< 71 Then tmp$=tmp$+Mid$(pxl$,n,1) Else co$=Hex$(Asc(Mid$(pxl$,n,1))-71) Inc n:nmb=Val("&H"+Mid$(pxl$,n,1)) tmp$=tmp$+String$(nmb+1,co$) EndIf Inc n:Loop Until n>Len(pxl$) expand$=tmp$ End Function '---------- 'Make QBert jump in requested direction Sub Qjump(d) 'For Demo .. has to be included in Main Local x,of ',ox,oy 'FRAMEBUFFER Write L 'ox=qb_x:oy=qb_y: Select Case d Case d_UL ' jump Up and left of=7 For x=qb_x To qb_x-15 Step -2 Inc qb_y,-3 cls Sprite write 2-(of=0), x-2, qb_y-sw(of)-1,0 Inc of,-1 FRAMEBUFFER COPY F, L, B Pause 40 Next Inc qb_x,-16 Case d_UR ' jump Up and right of=0 For x=qb_x To qb_x+15 Step 2 Inc qb_y,-3 cls Sprite write 2-(of=7), x, qb_y-sw(of),1 'oy=qb_y-sw(of) Inc of FRAMEBUFFER COPY F, L, B Pause 40 Next Inc qb_x,16 Case d_DL ' jump Down and left of=7 For x=qb_x To qb_x-15 Step -2 Inc qb_y,3 cls Sprite write 4-(of=0), x-6, qb_y-sw(of)-1,0 Inc of,-1 FRAMEBUFFER COPY F, L, B Pause 40 Next Inc qb_x,-16 Case d_DR ' jump Down and Right of=7 For x=qb_x To qb_x+15 Step 2 Inc qb_y,3 cls Sprite write 4-(of=0), x+2, qb_y-sw(of)-1,1 Inc of,-1 FRAMEBUFFER COPY F, L, B Pause 40 Next Inc qb_x,16 End Select print @(0,0) str$(qb_x,4) str$(qb_y,4) " " End Sub ' 'Draws the playground in colors 1 (top) 2 (left) and 3 (right) Sub pyra C1,c2,c3 tx=112 For y=0 To 6 For n=0 To y:field tx+32*n,32+24*y,c1:block tx+32*n,40+24*y,c2,c3:Next Inc tx,-16 Next End Sub '------- to recolor just the Top Sub Fields c1 tx=112 For y=0 To 6 For n=0 To y:field tx+32*n,32+24*y,c1:Next Inc tx,-16 Next End Sub '------------- Sub field x,y,c Triangle x,y+8,x+16,y,x+16,y+16,c,c Triangle x+32,y+8,x+16,y,x+16,y+16,c,c End Sub Sub Block x,y,c1,c2 'left Triangle x,y,x+16,y+8,x,y+16,c1,c1 Triangle x,y+16,x+16,y+8,x+16,y+24,c1,c1 'right Triangle x+17,y+8,x+32,y,x+32,y+16,c2,c2 Triangle x+17,y+8,x+17,y+24,x+32,y+16,c2,c2 End Sub colr: Data RGB(BLUE),RGB(GREEN),RGB(CYAN),RGB(RED) Data RGB(MAGENTA),RGB(YELLOW),RGB(WHITE),RGB(MYRTLE) Data RGB(COBALT) ,RGB(MIDGREEN),RGB(CERULEAN),RGB(RUST) Data RGB(FUCHSIA),RGB(BROWN),RGB(LILAC) 'levelcolors 'colors per round:Top, left, right,transition,target Levels: Data "93806","68E09","7280A","B3106" Data "98E62","431B6","E3896","6009E" Data "36C09","BA807","98E07","6A809" Data "ACE69","90046","6A84B","531B6" Data "E3869","28E96","8A8B7","6A1B4" Data "28E96","B3146","E3869","E0096" Data "96C35","7A88B","28E96","6389E" Data "98E62","E0096","6389E","6A1B4" field: Data 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,1,0,1,0,0,0,0,0,0 Data 0,0,0,0,0,1,0,1,0,1,0,0,0,0,0 Data 0,0,0,0,1,0,1,0,1,0,1,0,0,0,0 Data 0,0,0,1,0,1,0,1,0,1,0,1,0,0,0 Data 0,0,1,0,1,0,1,0,1,0,1,0,1,0,0 Data 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0 'Compressed sprite Data 'always facing left, have to be mirrored when looking to the right '2nd sprite is the Object jumping '1 Bert (4 Sprites) qb1: Data 16,16 Data "GF","GF" Data "0CCEG3CCEEG3","4CCEE0K2CCEEG2","4S2EE774CCU200","04S3874S2EE00" Data "004S2874S2U20","G24CC44C4S2EE0","G344C4S4EE0","G3K2S5EE0","G344CC4S400" Data "G4K2CC4CCG2","G5K2S2G3","G4K204CG4","G2440C4C44CG3","G4K20044CG2""" Data 16,16 Data "0CCEG3CCEEG3","4CCEE0K2CCEEG2","4S2EE874CCU200","04S3874S2EE00" Data "004S2774S2U20","G24CC44C4S2EE0","G344C4S4EE0","G3K2S5EE0","G344CC4S400" Data "G4K2CC4CCG2","G5K2S2G3","G6400CG4","G54400CG4","G24C004S2G4" Data "G344C4044CG3","G544G24CG2" Data 16,16 Data "GF","GF","G7S3G3","G5K4S200","G5884884C440","G5874874CC44","G4EK5CK2" Data "G2EES344S244","00ES9K2","0ECCK2C4C4C4C44","0C8844044CK40","04884G2K500" Data "0044G3K4G2","G74004G3","G5CC400S200","G3EC400EEC4G2" Data 16,16 Data "G7S3G3","G5K4S200","G5774774C440","G5884884CC40","G4E884884CK2" Data "G2EES344S244","00ES9K2","0ECCK2C4C4C4C44","0C8844044CK40","04884G2K500" Data "0044G3K4G2","G74G24G2","G74G24G2","G74G24G2","G5CC400S200","G3EC400EEC4G2" 'BALL red (2 Sprites) Data 16,12 Data "GF","GF","GF","GF","G5K4G4","G3K8G2","G2K27K600","00K27K80","00K88K20" Data "00K78K30","G2KA00","G4K6G3" ' Data 16,12 Data "GF","GF","G5K4G4","G3K8G2","G2K27K600","00K27K80","00KC0","00K98440" Data "00K88K20","G2K588K200","G3K8G2","G5K4G4" 'Ball GREEN (2 Sprites) Data 16,12 Data "GF","GF","GF","GF","GF","GF","G5Q3G5","G3Q7G3","G2Q27Q32AG2" Data "G2AA7Q42AG2","G2Q62AAG2","G3Q7G3" ' Data 16,12 Data "GF","GF","GF","GF","G5Q3G5","G3Q7G3","G2Q27Q5G2","G2AA7Q42AG2" Data "G2Q72AG2","G2Q522AAG2","G3Q222Q2G3","G5Q3G5" 'MBall Coily Drop (2 Sprites) Data 16,16 Data "GF","GF","GF","G4L5G4","G2L2V3L2G2","0055F7L700","055F77L80","055F77L80" Data "55FLC","LB8585","LA85885","0L7O400","00L4885O2G2","G3L488G4","GF","GF" ' Data 16,16 Data "G4L5G4","G2L9G2","00L3V3L300","0L2F7L80","L2F77L9","55FLC","LB8585" Data "LB8585","LA85885","L8O55","0L5885O350","00L6O3500","G2L2O455G2","G4L5G4" Data "GF","GF" 'Coily 16x32 up (2 Sprites) Data 16,32 Data "GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF" Data "GF","00FF0V3G6","0FL7G5","0FL8G4","0FL9G3","FLAG3","FL2G4L2G3" Data "07005500L3G3","0FL8G4","00FL7G4","00L6G6","00F5G65G3","00F55G355G4" Data "G2FL605G2","G3FL30055G2","GB5G2","GF" ' Data 16,32 Data "00FF0FFG8","0FL5G7","0FL5V2G4","0FL8FG3","FLAG3","FL4G3L2G2","055G7L200" Data "07007G65500","GBF550","G35V2G3F550","00FL5F00F550","0FL200L2005500" Data "L3FG2L30500","FL2FG3L3G2","0FL2V250L2G2","00FL6055G2","G4L300L200" Data "GB5500","GBF550","00V6G2F550","0FL700F550","0FL2G2L20L20","0F55G3FL20500" Data "0FL50L3G2","G45500L3G2","G9L2G2","G9L2G2","G9L2G2","G2FG5L2G2" Data "G25FG3F55G3","G355V255G4","G555G7" 'Coily 16x32 down (2 Sprites) Data 16,32 Data "GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF","GF" Data "GF","00FF0FF5FG6","0V555FG5","078787L3FG4","05N2L5FG3","L70L2FG2" Data "L6G255FG2","0L4G355FG2","07007G2L3G3","G2L70FG2","G3L4005FG2","G8F55FG2" Data "G25G3FL2G3","G35V3L2FG2","G5L405F00","GB5F00","GB5G2" ' Data 16,32 Data "00FF0FFG8","0V55G7","07878755V2G4","05N2L5FG3","LBFF00","L5G3L2F00" Data "0L4G4L2F0","07007G655F0","GC55F","G35V2G455F","00L6FG255F","0L300L2FL2F0" Data "L3FG4L3F0","0505FG3L3F00","00505V2L4G2","G250L500F00","G4L2G355F0" Data "GB55F0","GC55F","005V5G355F","0L7FG255F","0L3G35FL3F","0L2G5L3F0" Data "0LBF00","G4L4G5","GAV200","G9L2F00","G9L2F00","G2FG5L300","G25FG3FL2G2" Data "G355V255G4","G555G7" ' WrongWay (2 Sprites) Data 16,16 Data "GF","00L2G45G4","0FFG655G3","F00F005500505G2","F500L600500","0FL805G2" Data "00F5878755005500","0FF558787L3050","FF57755785005005","0FN3557G6" Data "FF7788755G6","FFN28755V25500","FF5N288700FG3","0FF55778700FFG2","V477G8" Data "00V2GA" ' Data 16,16 Data "00L2G45G4","V25G65G3","FF0FFG4505500","FG455055G250","FF00L5G2500" Data "0FL6G2L20","00L27L3055055","0FL37L4G25","V2775575FFG4","0FN3557G6" Data "FFN4L2G5","FF7887755F5G4","FF57O2770FL200","0FF55787G2FG3","V477G4F500" Data "00V2GA" '6 Ugg (2 Sprites) Data 16,16 Data "G57G8","G3705G8","00700F5G8","G250F550FF00550","G250F05FF500550" Data "00F500F55F550505","00F55FF5F578L3","00F0L2F57885500","G3L378875G2" Data "00FFL387L300","0L978500","50L6F775G2","500L5F7FF500","0500L4V20L2" Data "0050050L4G3","GAL200" ' Data 16,16 Data "G47G9","G2705G9","0700F5G9","0050FL20FF00550","7050F005FF500550" Data "0F5G2FL40585","0FL2FF55F58L3","0F00L3F58L200","G3L2F58L2G2","00FFL900" Data "0L977500","50L6F775G2","500L5F8FF500","0500L4V20L2","0050050L4G3","GAL200" '7 Slick (2 Sprites) Data 16,16 Data "GF","GF","G9EG4","G6E0E00EG2","G5U30EG3","G4EEAEAEG4","G3EAEEAEAEG3" Data "G27AA7Q2E2G3","G278787AA2A2G2","00A78787A2A22G2","00AN42A22AG2" Data "00A72272AI3G2","00I7A2G3","G228822AI2G3","G3I6G4","G2I20I2G5" ' Data 16,16 Data "G6E0E00EG2","G5U30EG3","G4EEAEAEG4","G3EAEEAEAEG3","G27AA7Q32G3" Data "G277878AA2A2G2","00A77878A2A2AG2","00AN42AI2G2","00A72272A22A2G2" Data "002288I5G3","G2288I2A22G3","G3I7G3","G42G222G4","G42G22G5","G42G22G5" Data "G3I20I2G4" '8 Sam (2 Sprites) Data 16,16 Data "GF","GF","G9EG4","G6E0E00EG2","G5U5G3","G4U3AE00E00","G3EAEAAEAEEG2" Data "G2Q72G3","G287887O4G2","00A87887A2A22G2","002882882AI2G2","00I5AI3G2" Data "00I9G3","G2288I4G4","G3I6G4","G2I20I2G5" ' Data 16,16 Data "G6E0E00EG2","G5U30EG3","G5EAEAE00E00","G3EEAEAEAEEG2","G2Q6E2G3","G2O8G3" Data "00A87887A2A22G2","002872872AI2G2","00I5AI3G2","00I9G3","G2288I5G3" Data "G2I7G4","G322G222G4","G42G22G5","G42G22G5","G2I20I2G5" '9 Disc (4 Sprites) Data 16,12 Data "GF","G54499G5","G2K6P2G2","0K8P40","K2I34P66","4I66P3M2","3I4M88" Data "J2I2M6O2","0J4226683O20","G2J483838G2","G53383G5","GF" ' Data 16,12 Data "GF","G52244G5","G2I6K2G2","0I8K40","I2M32K69","2M69K3P2","3M4P88" Data "J2M2P6O2","0J4669983O20","G2J483838G2","G53383G5","GF" ' Data 16,12 Data "GF","G56622G5","G2M6I2G2","0M8I40","M2P36I64","6P64I3K2","3P4K88" Data "J2P2K6O2","0J4994483O20","G2J483838G2","G53383G5","GF" ' Data 16,12 Data "GF","G59966G5","G2P6M2G2","0P8M40","P2K39M62","9K62M3I2","3K4I88" Data "J2K2I6O2","0J4442283O20","G2J483838G2","G53383G5","GF" ' end Visit Vegipete's *Mite Library for cool programs. |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4246 |
Nice...very smooth moves... You did not color the top tiles yet... Insert lines 165..167 PicomiteVGA PETSCII ROBOTS |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1109 |
Here's a short program with the sprites converted to CSub form, as used by Picomite(VGA) firmware 5.0708b16 (or newer.) This just displays them on screen. I've created the various required mirror images - Ugg and Wrongway were a bit tricky because they actually need to be mirrored at 45 degrees. Next I need to compress them... Visit Vegipete's *Mite Library for cool programs. |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1114 |
good work, Ugg and Wrongway have to be, the way they are ..:-) Because in the Game, they use a twisted perspective (Sides as top), they are displayed as they are. Cheers Mart!n 'no comment |
||||
lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3150 |
That's what it looks like on a PicoMite with ILI9488 with this code: 'autosave Option DEFAULT INTEGER If MM.Device$="PicoMiteVGA" Then MODE 2 Else FRAMEBUFFER create FRAMEBUFFER write F EndIf Dim glof(50) Restore GlyphOff Read n : glof(0) = n For i = 1 To n:Read glof(i):Next CLS Text MM.HRes/2,0,"PI*Bert Sprites by Martin H.","CT" Text MM.HRes/2,10,"Converted to CSub by Vegipete","CT" spad=Peek(cfunaddr Glyphs) x = 10 : y = 40 For i = 1 To glof(0) Blit memory spad+glof(i),x,y Inc x,20 If i = 12 Then x = 10 : Inc y, 20 If i = 24 Then x = 10 : Inc y, 40 If i = 36 Then x = 10 : Inc y, 20 Next i If MM.Device$="PicoMite" Then FRAMEBUFFER copy f,n End I don't know if the blank sprites are supposed to be blank. ~ Edited 2023-09-18 21:44 by lizby PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4246 |
Hi lizby, Your image is okay. There are no blank sprites. Some are vertically larger.... Volhout PicomiteVGA PETSCII ROBOTS |
||||
lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3150 |
Ah, got it. Thanks. PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
Page 1 of 2 |
Print this page |