It is currently Wed Oct 18, 2017 6:51 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 51 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
PostPosted: Thu Oct 12, 2017 8:56 am 
Offline

Joined: Sun Jan 31, 2016 9:55 pm
Posts: 31
I wouldn't worry too much yet about using up everything the MMC3 has available. The MMC3 can handle games like Super Mario Bros 3 and Kirby's Adventure, which have lots of enemies, graphics, and moves.


Top
 Profile  
 
PostPosted: Thu Oct 12, 2017 10:05 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1772
Location: DIGDUG
IMAGICA wrote:
[color=#FF0000]

Before I fix. Is there another way to manage jumping? Look at from Jump to Animation


I think you would benefit from testing out 6502 code and stepping through it, to see how it all works.

https://skilldrick.github.io/easy6502/

This is a nice online 6502 emulator. Try writing some small test code.


To answer your question, seems to be about program flow control. Right? When to JMP and when to JSR and when to branch? I'm not sure I understand your question.

EDIT - or do mean having a character jump? Like handling the animation and collision detection of a jump?

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Last edited by dougeff on Thu Oct 12, 2017 1:49 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Thu Oct 12, 2017 11:38 am 
Offline

Joined: Tue May 28, 2013 5:49 am
Posts: 802
Location: Sweden
IMAGICA wrote:
May need another Thread: Ok, Doing that in mind, and I know it's way off topic. For This game play, Should the sprites be bigger because you'll be flying via mid air dashing, shooting projectiles and wall jumping? I may need more ram than MMC3 chip for ai and other stuff. Maybe I need to understand how to compress code and to do this NMI Stuff before this challenge.


Before I fix. Is there another way to manage jumping? Look at from Jump to Animation
I think you should focus on getting your core working if it isn't already. And by core I mean your main loop and NMI. If you start adding lots of extra stuff before everything works as intended it will just complicate things even further.

I doubt you will need to compress any code. Get something smaller working first, and do things one step at a time. That's how I do it anyway.


Top
 Profile  
 
PostPosted: Thu Oct 12, 2017 3:55 pm 
Offline

Joined: Thu Jul 13, 2017 5:17 pm
Posts: 20
dougeff wrote:

EDIT - or do mean having a character jump? Like handling the animation and collision detection of a jump?

Character.


Top
 Profile  
 
PostPosted: Thu Oct 12, 2017 5:13 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10056
Location: Rio de Janeiro - Brazil
The basics behind platformer physics is to have horizontal and vertical speeds for each object, that you add to their coordinates every frame. When characters are stationary, both speeds are 0. Pressing left/right gradually decreases/increases the horizontal speed by the acceleration value. The vertical speed can be affected by gravity (when there's no ground below a character, increase its vertical speed by the gravity value), or by jumping. Jumping can be implemented by setting the vertical speed to a high negative number, which will cause the character to move up pretty fast, and then gravity will kick in and gradually modify the vertical speed back into a positive value, eventually causing it to fall back down.


Top
 Profile  
 
PostPosted: Thu Oct 12, 2017 5:16 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1019
You can comment your code to describe what it's doing. What does a 1 in JumpState+2 mean? Why are you comparing JumpState+1 to #$14? What does #$14 represent?

Is player+1 the Y position?

I don't really follow what it's doing, it needs more context.

It requires understanding of 16 bit math, but here's fixed jump height code:

Code:
;playerY is the player's Y pixel position
;playerYSub is the player's Y position in between pixels (fractional position. 1/256th of a pixel)

;playerYSpd is the player's pixel speed (pixels per frame)
;playerYSpdSub is the player's fractional pixel speed (1/256th of a pixel per frame)

;grounded: If the player is on the ground, this is non zero
   
GRAVITY = 8
JUMPSTRENGTH = -512
GROUNDPOSITION = 200

   lda grounded;If the player is in the air, we need to
   beq addgravity;add gravity
   
   ;If here, the player is grounded and can jump if they press A
   
   lda buttons;if the player did not press A
   bpl nojump;no jump happened
   
   ;If here, the player pressed A, and we should jump
   
   lda #low(JUMPSTRENGTH);Set the player's speed
   sta playerYSpdSub;to the jump strength
   
   lda #high(JUMPSTRENGTH)
   sta playerYSpd
   
   ;and make the player not grounded
   lda #0
   sta grounded
   
   
   jmp updateyposition
addgravity:
   lda #low(GRAVITY);add gravity to the player's speed
   clc
   adc playerYSpdSub
   sta playerYSpdSub
   
   lda #high(GRAVITY)
   adc playerYSpd
   sta playerYSpd
   
updateyposition:
   ;Add speed to position to update the position
   lda playerYSpdSub
   clc
   adc playerYSub
   sta playerYSub
   
   lda playerYSpd
   adc playerY
   sta playerY
   
   ;If the player is not below the ground
   cmp #GROUNDPOSITION
   bcc jumpdone;We're done
   ;Otherwise, we ground them
   lda #$FF
   sta grounded
   
   ;set their falling speed to zero
   lda #0
   sta playerYSpdSub
   sta playerYSpd
   
   ;Set their position to the ground
   lda #GROUNDPOSITION
   sta playerY
   
   lda #0;The ground is a pixel position
   sta playerYSub;so the fractional part is just zero

jumpdone:
nojump:


Here's what it looks like:
Image
Edit: Actually that's probably not quite what it should look like. What I hacked it into probably ran it twice per frame instead of once. Changing GRAVITY to 24 would probably get a similar enough result to the animation.

_________________
https://kasumi.itch.io/indivisible


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 51 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group