Changing the sword action in the scroller platformer

pit.baldriz

New member
Hi guys!

I´m trying to figure it out how to change the action of the sword on the scrolling platform basic game. I want to have a new item that comes from the boxes that are a heart and will increase the player´s health by 1 when is lower than 3 (that´s the total health my player can have).

captura_ejemplo_01.png


So I have some questions maybe someone could help:

1. How can I change what´s showing up on the box if I want to have different items?
2. How can I set the action?

Thanks in advance!!
 

dale_coop

Moderator
Staff member
I think the content of the prize box is defined by a constant ("OBJ_PRIZE" in "Project Settings > User Constants"). Change this value to get another object.
Note: the objects under "Game Objects" go from "0" to "15" (the "Player" is "0"... and "Effect 7" is "15").
 

pit.baldriz

New member
Dale, I could change the sword! Thanks for your help. Now, how can I change one of my objects to gain 1 health?
 

dale_coop

Moderator
Staff member
If you are using the "Health Pickup" object, go to "Project Settings > Script Settings", select the " assign the "Power Up 0" element (it corresponds to the first game object) and assign the "Powerup_IncreaseHealth.asm" script to it (the script is "Routines\Basic\ModuleScripts\PowerUpCode\").

2019-07-02-09-25-59-Project-Settings.png


Now, when your player will take this pickup, he will gain 1 health.

Note: you will have to add a new "SFX_INCREASE_HEALTH" SFX (in the nesmaker hierarchy, under "Sound > SFX"), for the sound played. Else you will have an error (unknown label) when Export&Test.
 

pit.baldriz

New member
Thanks a lot Dale for your help! I did what you say and could add the health pickup, thanks!!

Now I´m having some issues maybe you can help me. I record this video that shows 3 different attempts to illustrate everything:

[media]https://youtu.be/1AnCts9SKks[/media]

1st attempt: works OK, the player loses health and gains it again with the item.

2nd attempt: works badly. The player loses health when picking up the item while having full health.

3rd attempt: if the player doesn't pick up the item it stays forever in all screens.
 

dale_coop

Moderator
Staff member
I think it's because when you lose, the game does NOT reset the health variable (to 3). The hud displays a incorrect value at start.

So you have to add it yourself. Modify the PlayerLoseLife script... and add those lines:
Code:
	LDA #$03
	STA myHealth
(At the end of the script, for example)

If you're not sure, share your script with the modifications, I will check ;)
 

pit.baldriz

New member
Thanks Dave! I tried adding those lines but I got a compilation error. Here is the code I have for PlayerLoseLife:

Code:
;;; do loss of life stuff here
	DEC myLives
	LDA myLives
	BNE gameNotOver
	;;do gameover stuff here.  Warp to screen?  Show animation?  Just restart?
	JMP RESET
	
gameNotOver:

;;;;;
;;; do warp to continue screen stuff here.
LDA #$00
STA newGameState
 LDA continueMap
 clc
 ADC #$01
 STA temp
 GoToScreen continueScreen, temp, #$04
 LDA #$00
 STA playerToSpawn
; LDX player1_object
; DeactivateCurrentObject
 LDA #$01
 STA loadObjectFlag

 
LDA continuePositionX
STA newX
LDA continuePositionY
STA newY
 

dale_coop

Moderator
Staff member
Ok. Try with this one:

Code:
;;; do loss of life stuff here
	DEC myLives
	LDA myLives
	BNE gameNotOver
	;;do gameover stuff here.  Warp to screen?  Show animation?  Just restart?
	JMP RESET
	
gameNotOver:

	;;;;;
	;;; do warp to continue screen stuff here.
	LDA #$00
	STA newGameState
	LDA continueMap
	clc
	ADC #$01
	STA temp
	GoToScreen continueScreen, temp, #$04
	LDA #$00
	STA playerToSpawn
	; LDX player1_object
	; DeactivateCurrentObject
	LDA #$01
	STA loadObjectFlag

	LDA continuePositionX
	STA newX
	LDA continuePositionY
	STA newY

	;; player1 reset health:
	LDA #$03		;;  <--- HERE reset with your Health value
	STA myHealth
 

pit.baldriz

New member
Thanks for your help Dale!

I tried the new code you sent, but the problem is still there:

RamenHealthError.gif


I´m so horrible at coding, is hard not to get frustrated.
 

dale_coop

Moderator
Staff member
Your player object heath is set to "3", right?
Not sure what causes this issue...

If you want you could send me your project zipped, I could check and tell you how to fix this issue (more precisely, I'd need the project .MST file, the GraphicAssets and the GameEngineData folders).
 

pit.baldriz

New member
Yes, is set to 3:

player-health.jpg


Dale, I don´t know what is wrong, but I appreciate your help a lot, thank you! I´ll send you a link to my dropbox with the game.
 
Top Bottom