|
Post by Mark Dunham on Feb 17, 2020 16:35:05 GMT -5
Is anyone interested on working on a side scroller framework. Things I think would be good to have planned out are - Movement
- Jumping
- Collision Detection
- Music
- Sounds
I have done some of this in other games. I have never gotten a good handle on jumping. I have a copy of a mario bros style game that has jumping and is really cool but the code is not structured in a way that new person to programming/coding would get it all right away. Just seeing if there is any interest out there. I believe if we were to make some easy to follow game engines along with useful applications and were to highlight them it would pull more people to Liberty Basic.
|
|
|
Post by Carl Gundel on Feb 17, 2020 17:59:58 GMT -5
Is anyone interested on working on a side scroller framework. Things I think would be good to have planned out are - Movement
- Jumping
- Collision Detection
- Music
- Sounds
I have done some of this in other games. I have never gotten a good handle on jumping. I have a copy of a mario bros style game that has jumping and is really cool but the code is not structured in a way that new person to programming/coding would get it all right away. Just seeing if there is any interest out there. I believe if we were to make some easy to follow game engines along with useful applications and were to highlight them it would pull more people to Liberty Basic.
Hey Mark, it's a great idea. Do you have any simple side scrolling example programs?
|
|
|
Post by Mark Dunham on Feb 17, 2020 20:30:04 GMT -5
Is anyone interested on working on a side scroller framework. Things I think would be good to have planned out are - Movement
- Jumping
- Collision Detection
- Music
- Sounds
I have done some of this in other games. I have never gotten a good handle on jumping. I have a copy of a mario bros style game that has jumping and is really cool but the code is not structured in a way that new person to programming/coding would get it all right away. Just seeing if there is any interest out there. I believe if we were to make some easy to follow game engines along with useful applications and were to highlight them it would pull more people to Liberty Basic.
Hey Mark, it's a great idea. Do you have any simple side scrolling example programs? Carl,
I have quite a few examples I will post links from my dropbox.
#1 Comes from Cundo and I think it is really cool would be nice to make it beginner friendly it is mario like.
#2 Comes from Stelios and it is another mario type cleaner.
#3 Is from My brother and I it is a drill game that we built using a level editor I created he did the art.
#4 Is another from My brother and I it is a work in progress called DropMan he did all the art and converted a lot of the code I am working on to optimize.
#5 Is one of the first games I created all the art for it is a simcity style clone. It a demo still needs game engine.
#6 Is just the level editor for reference I created all the code and my brother did the art again.
I also have some RPG games like final fantasy started that I fist started a few years ago with mostly borrowed art but I think there is a huge foundation to build off of here I hope anyway. I really love this community and think together we can make some awesome programs. Let me know if you want to see more. Thanks.
|
|
|
Post by Carl Gundel on Feb 17, 2020 20:32:15 GMT -5
Hey Mark, it's a great idea. Do you have any simple side scrolling example programs? Carl, I have quite a few examples I will post links from my dropbox. You've been busy. Give me a couple of days to have a look.
|
|
|
Post by Mark Dunham on Feb 17, 2020 20:38:09 GMT -5
Carl, I have quite a few examples I will post links from my dropbox. You've been busy. Give me a couple of days to have a look. Thanks
|
|
|
Post by Mark Dunham on Feb 24, 2020 10:16:54 GMT -5
I have started a simple project to simplify jumping. I think I can get it simplified in a way someone new to programming can understand. I hope it will make me understand it better myself. If anyone has suggestions they are greatly appreciated.
|
|
|
Post by Rod on Feb 24, 2020 10:39:33 GMT -5
Yes you will get interest with this project but folks like code. We did a Sewer Rat Cid a while ago but I have lost the code. This has some jump code and the physics are good. jbfilesarchive.com/phpBB3/download/file.php?id=563But lets see what you are trying to do.
|
|
|
Post by Carl Gundel on Feb 24, 2020 10:50:40 GMT -5
I've had a look at these two so far.
These show what the potential could be. It would be really cool to produce something like this that is very modular and easy to understand how to adapt.
A simple game based on such a framework would also be very cool to include with a version of Liberty BASIC.
Ever play Commander Keen?
|
|
|
Post by Mark Dunham on Feb 24, 2020 21:48:42 GMT -5
I've had a look at these two so far. These show what the potential could be. It would be really cool to produce something like this that is very modular and easy to understand how to adapt. A simple game based on such a framework would also be very cool to include with a version of Liberty BASIC. Ever play Commander Keen? I have not is it built in LB?
|
|
|
Post by Mark Dunham on Feb 24, 2020 21:55:22 GMT -5
Yes you will get interest with this project but folks like code. We did a Sewer Rat Cid a while ago but I have lost the code. This has some jump code and the physics are good. jbfilesarchive.com/phpBB3/download/file.php?id=563But lets see what you are trying to do. Rod I am still cleaning this up but I thought I would show my work. It still has issues and it is not easily understood I am in favor of variables that state what they are like CanJump$ = "TRUE" but like I said needs work can't jump and move left and right at the same time and jump height is not always the same. I really want to make this simple for the world.
'WORKING ON SIMPLIFYING JUMPING 'http://flatformer.blogspot.com/2010/02/making-character-jump-in-xnac-basic.html
nomainwin
GameSpeed = 60
DMSpeed = 9 'Define the walking distance in pixels for the player DMGravity = 9 'Set the speed of gravity for the player
DMX = 10 DMY = 350 DMdelta = 12 'Drop Man Speed DMdir = 12 'Drop Man Direction
gravity=1 'pull of gravity on Water Projectil
list$ = ""
BG = 4 BGSP = 0
gosub [GamingWorld.Window] gosub [Load.Sprites]
[Start.GamingWorld] timer 0 #GamingWorld, "setfocus" DMWalking = 0 'Init the game variables DMCanJump = 0 'Init the game variables DMJumpCount = 0 'Init the game variables timer GameSpeed, [GamingWorld.Loop] wait
[GamingWorld.Loop]
'gosub [Load.Data] gosub [CheckVirtual.Keys] 'gosub [UpdateStatus.Bar] 'gosub [Background.Move] 'gosub [Move.Npc] 'gosub [Move.Water.Projectile] 'gosub [Collision.Detection] 'Resolve any collisions gosub [ApplyGravity] gosub [ApplyMovement] #GamingWorld, "spritexy? DM DMX DMY" 'Get the Drop Man current cordinates
#GamingWorld, "drawsprites" wait
[GamingWorld.Window] 'SET OUR WINDOW WIDTH AND HEIGHT WindowWidth = 640 WindowHeight = 480
UpperLeftX = int((DisplayWidth - WindowWidth)/2) UpperLeftY = int((DisplayHeight - WindowHeight)/2)
graphicbox #GamingWorld.gbx, 0,0, WindowWidth, 20
open "NAME HERE" for graphics_nsb_nf as #GamingWorld #GamingWorld, "trapclose [GamingWorld.Quit]" #GamingWorld, "when characterInput [Check.Keyboard]"
'Setup Status Bar #GamingWorld.gbx, "disable" #GamingWorld.gbx, "font ar destine bold 9 16" '#GamingWorld.gbx, "down; fill black; color Red; backcolor black" #GamingWorld.gbx, "down; fill black; color Blue; backcolor black"
return
[Load.Sprites] loadbmp "DMJ1", "DropManJump_1.bmp" loadbmp "DMJ2", "DropManJump_2.bmp"
#GamingWorld, "addsprite DM DMJ1" #GamingWorld, "spritexy DM "; DMX; " "; DMY;
return
'##################################################################################### '## Check for Keyboard Character Input ## '##################################################################################### [Check.Keyboard] if len(Inkey$) = 2 then key = asc(right$(Inkey$,1)) else key = 0 char$ = Inkey$
if char$ = "l" or char$ = "L" then Level = Level + 1 end if
if char$ = "a" or char$ = "A" then gosub[Move.Left] if char$ = "d" or char$ = "D" then gosub[Move.Right]
'if char$ = "f" or char$ = "F" then gosub[Projectile.Fire]
Inkey$ = "" wait
'##################################################################################### '## Quit the game ask Yes/No ## '##################################################################################### [GamingWorld.Quit] timer 0
confirm "Are you sure you want to quit?"; answer$ if answer$ = "yes" then close #GamingWorld end end if
timer GameSpeed, [GamingWorld.Loop]
'##################################################################################### '## Gravity,Jump & collisions With Blocks ## '#####################################################################################
[ApplyGravity]
if DMGravity < 0 then DMJumpCount = DMJumpCount + 1 ' Check if the player is mid-air from a previous jump and increase the counter
if DMJumpCount > 10 then ' How high u jump Check the Jump counter: If counter > 6 then revert the player's gravity DMGravity = DMGravity * -1 DMJumpCount = 0 end if
#GamingWorld, "spritexy DM "; DMX; " "; DMY + DMGravity ' Move the player to the new location
if (DMY + DMGravity) > WindowHeight - 120 then ' Check if the player fell off the screen 'Loose a life Lives = Lives - 1 ' Play a sound 'playwave "sounds\LavaHitWater.wav",sync 'goto [GamingWorld.Quit] end if
if DMY > 350 then DMY = 350
#GamingWorld, "spritecollides DM list$" ' Get the collision list
findLavaAsh = instr(list$,"LavaAsh") ' Resolve the collisions with blocks. if findLavaAsh > 0 then ' We only collide with tiles having the 'block' part in their name
if DMWalking = 0 then #GamingWorld, "spriteimage DM DM4" ' Check if player is walking and set the proper sprite
DMNewY = DMY ' We have a block, leave the player to his previous Y location.
if DMJumpCount > 0 then ' Check if the player was jumping DMJumpCount = 6 end if
#GamingWorld, "spritexy DM "; DMX; " "; DMNewY ' Move the player back to the previous location
DMCanJump = 1 ' Enable the player to jump again else DMNewY = DMY + DMGravity ' Set the new Y value - no need to redraw the sprite, it's already there. DMCanJump = 0 ' The player is already in the air. He cannot jump again. end if
' Go back return
[ApplyMovement]
'if DMWalking <> 0 then ' Apply the horizontal movement 'if DMJumpCount = 0 then ' Cycle through the player's sprite images if he's not jumping '#GamingWorld, "cyclesprite DM 1" ' Cycle through the player's images 'end if
TempDMX = DMX + DMSpeed * DMWalking ' Apply movement to the player and check for collisions #GamingWorld, "spritexy DM "; TempDMX; " "; DMNewY ' Move the player to the new location '#GamingWorld, "spritecollides DM list$" ' Get the collision list
'findLavaAsh = instr(list$,"LavaAsh") ' Resolve the collisions with blocks.
if findLavaAsh > 0 then ' We only collide with tiles having the 'block' part in their name DMNewX = DMX ' Move the player to the previous location DMWalking = 0 ' Stop the player from walking #GamingWorld, "spritexy DM "; DMNewX; " "; DMNewY ' Move the player to the previous location else DMNewX = TempDMX ' Keep the current X position end if
gosub [MoveSprites] ' Move the sprites
if DMJumpCount = 0 then ' Reset the player unless he is jumping DMWalking = 0 ' Stop the player from making another step end if 'end if
' Go back return
[MoveSprites] ' Get the screen center #GamingWorld, "home;posxy xHome yHome"
' Calculate the distance between the player position and a fixed location on the screen. ' If the player is below the location then move the player sprite else move the tiles. if DMNewX < 200 And DMWalking = 1 then ' Move the player moveTo = 0 else ' Move the tiles moveTo = -1 * DMSpeed * DMWalking end if
' Check if the player is walking if moveTo <> 0 then
' Move the player #GamingWorld, "spritexy DM "; DMX; " "; DMNewY
'Move the blocks 'for counter = 1 to LevelLavaAsh 'Move the blocks '#GamingWorld, "spritexy? LavaAsh"; counter; " getX getY" '#GamingWorld, "spritexy LavaAsh"; counter; " "; getX + moveTo; " "; getY 'next end if
' Go back return
'##################################################################################### '## Check Virtual Keys ## '##################################################################################### [CheckVirtual.Keys]
if getKey(_VK_SPACE) and 32769 then goto [DM.Jump] if getKey(_VK_ESCAPE) and 32769 then goto [GamingWorld.Quit]
return
'##################################################################################### '## Move Hero ## '##################################################################################### [Move.Left] if DMX >= 0 then DMX = DMX - 5 DMWalking = -1 DMdir=DMdelta*-1 #GamingWorld, "spriteorient DM mirror" '#GamingWorld, "cyclesprite DM 1 once" '#GamingWorld, "spritexy DM "; DMX; " "; DMY 'playwave "sounds\DropManWalk.wav",async
return
[Move.Right] if DMX <= 605 then DMX = DMX + 5 DMWalking = 1 DMdir=DMdelta #GamingWorld, "spriteorient DM normal" '#GamingWorld, "cyclesprite DM 1 once" '#GamingWorld, "spritexy DM "; DMX; " "; DMY 'playwave "sounds\DropManWalk.wav",async
return
[DM.Jump] if DMCanJump = 0 then ' Make the player jump DMGravity = DMGravity * -1 ' Reverse the gravity value: This will make the player to move up instead of down 'playwave "sounds\DropManJump.wav", async ' Play the jump sound #GamingWorld, "spriteimage DM DM1" ' Change the sprite end if return
'##################################################################################### '## Function Section ## '##################################################################################### function getKey(key) calldll #user32, "GetAsyncKeyState",_ key as long,_ getKey as long end function
|
|
|
Post by Rod on Feb 25, 2020 6:13:23 GMT -5
So a tile based adventure. I see a couple of things that you might change. First is you have a mix of when characterInput and get key state. When you leave the window creation code block the when characterInput event is still running.
You will get much smoother animation if you decouple from the key board. The keyboard has a one shot instant event, a short delay then an automated series of key events while the key is held down. Non of this is in sync with your animation.
So the get key state code is much better suited to what you are doing. A single keypress sets the sprite off in the intended direction. That might go on till it hits something or you can introduce friction and the sprite walks a little then slows to a stop. Or you press S for stop and it stops at your command.
I expected your sprite to keep walking. Your code looks like you intend this.
As for the jump I am not sure yet but it looks like the trigger is not right, I would expect a jump to trigger once then not trigger again till the sprite lands. I need to play some more.
'##################################################################################### '## Check Virtual Keys ## '##################################################################################### [CheckVirtual.Keys] if getKey(65) then gosub [Move.Left] if getKey(68) then gosub [Move.Right] if getKey(83) then gosub [stop] if getKey(_VK_SPACE) and 32769 then goto [DM.Jump] if getKey(_VK_ESCAPE) and 32769 then goto [GamingWorld.Quit]
return
'##################################################################################### '## Move Hero ## '#####################################################################################
[stop] DMWalking = 0 return
|
|
|
Post by Mark Dunham on Feb 25, 2020 8:10:29 GMT -5
So a tile based adventure. I see a couple of things that you might change. First is you have a mix of when characterInput and get key state. When you leave the window creation code block the when characterInput event is still running. You will get much smoother animation if you decouple from the key board. The keyboard has a one shot instant event, a short delay then an automated series of key events while the key is held down. Non of this is in sync with your animation. So the get key state code is much better suited to what you are doing. A single keypress sets the sprite off in the intended direction. That might go on till it hits something or you can introduce friction and the sprite walks a little then slows to a stop. Or you press S for stop and it stops at your command. I expected your sprite to keep walking. Your code looks like you intend this. As for the jump I am not sure yet but it looks like the trigger is not right, I would expect a jump to trigger once then not trigger again till the sprite lands. I need to play some more. '##################################################################################### '## Check Virtual Keys ## '##################################################################################### [CheckVirtual.Keys] if getKey(65) then gosub [Move.Left] if getKey(68) then gosub [Move.Right] if getKey(83) then gosub [stop] if getKey(_VK_SPACE) and 32769 then goto [DM.Jump] if getKey(_VK_ESCAPE) and 32769 then goto [GamingWorld.Quit]
return
'##################################################################################### '## Move Hero ## '#####################################################################################
[stop] DMWalking = 0 return
Rod, thank you for the input so far the code comes from the Adventures of Drop man which I linked above. I actually don't want the character to move unless I am pressing the key to move left or right when I release the key I want him to stop. Spacebar should make him jump. This code is really meant for a Mario style game, get to the end of the level and go onto the next level. I hope to add the ability to shoot in the future first thing that needs to happen is the Jump and movement code need to get to where it is clean and easy to understand and also it needs to become portable so it can be used by anyone who is looking to do this. I am glad I have the community here to reach out to I want to use LB to make games I have spent countless hours with C++ and Unity and what happens is you get bogged down in libraries LB you just to get to work. Coding is a hobby of mine C++ made it feel like a job. Thanks for the input I will keep cleaning it up with your suggestions it is greatly appreciated.
|
|
|
Post by Mark Dunham on Feb 25, 2020 8:18:54 GMT -5
I've had a look at these two so far. These show what the potential could be. It would be really cool to produce something like this that is very modular and easy to understand how to adapt. A simple game based on such a framework would also be very cool to include with a version of Liberty BASIC. Ever play Commander Keen? I looked up commander keen I am going to try and find that for DOSBOX that game looks fun. I also remembered this game Pharaoh's Tomb that I used to play and thought it would be really cool as well.
|
|
|
Post by Rod on Feb 25, 2020 11:05:39 GMT -5
You can still achieve that with get keystate but much more smoothly. Each frame will check the keystate and if the key is pressed move, if not stop. So your animation runs at the frame rate not at the keyboard rate.
|
|
|
Post by Carl Gundel on Feb 25, 2020 13:12:02 GMT -5
I've had a look at these two so far. These show what the potential could be. It would be really cool to produce something like this that is very modular and easy to understand how to adapt. A simple game based on such a framework would also be very cool to include with a version of Liberty BASIC. Ever play Commander Keen? I have not is it built in LB? No, it's one of the early DOS side scrollers. I mention it because it is quite different from the Mario-type scrollers.
|
|