CPCWiki forum

General Category => Programming => Topic started by: djcaye on 15:20, 12 July 23

Title: Locomotive BASIC - Routine for Character Jump
Post by: djcaye on 15:20, 12 July 23
Hi everyone.

I am developing a DEMO in Locomotive BASIC, trying to get something similar to a Character moving as in a 80´s game (such Bomb Jack or similar).

Does anyone have any BASIC routine for using as a jump?? (I have got the usual as Locate + x+1 or y+1 regarding moving, but, with jump, even trying with arrays what I have doesn't work very well).

Regards.
Title: Re: Locomotive BASIC - Routine for Character Jump
Post by: abalore on 16:18, 12 July 23
Hi, you can find my game here which is 100% BASIC and has jump

https://www.cpcwiki.eu/forum/games/locomotive-basic-game-p4-return-to-ganymede/

But there are many different ways to implement a jump depending on what you want, pixel or character jump, with or without gravity simulation, controlled or not controlled jump... It would be great if you could tell us your design for the jump.
Title: Re: Locomotive BASIC - Routine for Character Jump
Post by: djcaye on 19:30, 12 July 23
Quote from: abalore on 16:18, 12 July 23Hi, you can find my game here which is 100% BASIC and has jump

https://www.cpcwiki.eu/forum/games/locomotive-basic-game-p4-return-to-ganymede/

But there are many different ways to implement a jump depending on what you want, pixel or character jump, with or without gravity simulation, controlled or not controlled jump... It would be great if you could tell us your design for the jump.
Hi!!

Great, I will read it and try to implement in my design. Of course, if can make it I will share my solution!!

Regards!!
Title: Re: Locomotive BASIC - Routine for Character Jump
Post by: djcaye on 17:25, 13 July 23
Hi again; 

As far as can read the code, the option that the game you share is similar to an array but my BASIC knowledge is very small.

The jump that I am trying to achieve is quite similar to "Bomb Jack" (esque). I mean, a bigger Jump as far as I push the button (up) and I would like to use it over a character.

The movent I am using is with a simply routine, such like this small xample:

190 LOCATE x%,y%
200 IF INKEY(1)=0 THEN x%=x%+1
210 IF INKEY(8)=0 THEN x%=x%-1
and in 220

IF INKEY(0)=0 THEN y%=y%-s (where S is an 2 dimension array
(first for Upping and second for downing).

But It doesn't work.

Thank you in advance!!
Title: Re: Locomotive BASIC - Routine for Character Jump
Post by: djcaye on 21:39, 13 July 23
Hi again.

Partly solve it, a simple example just a jump and falling down (of course, it can be improve a lot more)

1 rem rutina movimiento horizontal y salto con gravedad
2 rem error en los límites y0,y1,y2,y3
3 rem hay líneas que aun sobran
10 ON BREAK GOSUB 360
11 DEFINT a-z
18 SYMBOL 248,32,40,16,16,60,80,56,16
30 MODE 1:BORDER 0:INK 0,0:INK 0,1:INK 0,1
40 x%=9:y%=5:LOCATE x%,y%
60 xt%=x%:yt%=y%:p%=248:GOSUB 160
70 REM rutina inicio ciclo movimiento personaje+enemigo+limites+marcador
75 y%=y%+0.5:if y%> 24 then y%=24
78 if y%<5 then y%=5
80 IF INKEY(1)=0 and x%<39 THEN x%=x%+1:p%=251:GOSUB 170
90 IF INKEY(8)=0 and x%>2 THEN x%=x%-1:p%=250:GOSUB 170
100 IF INKEY(0)=0 THEN y%=y%-4:GOSUB 170
110 IF p%<>250 THEN p%=249:FRAME:GOSUB 170
120 GOTO 70
130 REM rutina fin juego
140 p%=238:CLEAR INPUT:FOR n%=0 TO 2000:NEXT:CLS:PEN 1:GOTO 10
150 CLS:PEN 1:INK 1,24:END
160 REM rutina animacion prota
170 LOCATE xt%,yt%:PRINT CHR$(32)
180 LOCATE x%,y%:PRINT CHR$(p%)
190 xt%=x%:yt%=y%
200 RETURN
360 end

Regards!!
Title: Re: Locomotive BASIC - Routine for Character Jump
Post by: McArti0 on 18:42, 14 July 23
y%=y%+0.5 it doesn't work like you think.
Title: Re: Locomotive BASIC - Routine for Character Jump
Post by: djcaye on 20:52, 14 July 23
Yes, indeed, better y%=y%+1  :D

Anyway I Fix it and share the routine.

10 ON BREAK GOSUB 360
11 DEFINT a-z
12 MODE 0:BORDER 0
18 SYMBOL 248,32,40,16,16,60,80,56,16
40 x%=9:y%=5:LOCATE x%,y%
60 xt%=x%:yt%=y%:p%=248:GOSUB 160
70 REM rutina inicio ciclo movimiento personaje+enemigo+limites+marcador
75 if y%<3 then y%=3
78 y%=y%+1:if y%>24 then y%=24
80 IF INKEY(1)=0 and x%<24 THEN x%=x%+1:p%=251:GOSUB 170
90 IF INKEY(8)=0 and x%>2 THEN x%=x%-1:p%=251:GOSUB 170
100 IF INKEY(0)=0 and y%>2 THEN y%=y%-2:GOSUB 170
110 IF p%<>250 THEN p%=249:FRAME:GOSUB 170
120 GOTO 70
130 REM rutina fin juego
140 p%=238:CLEAR INPUT:FOR n%=0 TO 2000:NEXT:CLS:PEN 1:GOTO 10
150 CLS:PEN 1:INK 1,24:END
160 REM rutina animacion prota
170 LOCATE xt%,yt%:PRINT CHR$(32)
180 LOCATE x%,y%:PRINT CHR$(p%)
190 xt%=x%:yt%=y%
200 RETURN
360 end


Title: Re: Locomotive BASIC - Routine for Character Jump
Post by: IndyUK on 22:35, 17 July 23
Hi,

In my BASIC demo of a platformer I simply used y-pos offsets. Here's a link to my post with demo video.

https://www.cpcwiki.eu/forum/programming/winape-turbo-mode/ (https://www.cpcwiki.eu/forum/programming/winape-turbo-mode/)

BTW - Don't be fooled by the speed of the demo. I'm running WinApe in Turbo mode which is why it's running at a decent speed.
Title: Re: Locomotive BASIC - Routine for Character Jump
Post by: Anthony Flack on 23:30, 31 July 23
To make a character jump in an arc, what you need to do is have a variable to represent the y velocity, let's call it dy for delta y.

Every update, y=y+dy

If you're on a platform, make dy = 0
When you press jump, make dy a negative number and your character will start moving up. The bigger the (negative) number, the higher the jump.
While you're in the air, every update dy = dy + g ; where g is the force of gravity pulling your character back down again.
Once dy > 0, start checking for platforms under the player's feet to see if they've landed. 

Store these numbers as floats, or at least at a higher precision than your character's location co-ordinates.


Powered by SMFPacks Menu Editor Mod