Jump to content
IGNORED

Various Questions


Gedalya

Recommended Posts

I have a few questions I'm hoping to get answered. I haven't readily seen an answer or an example that made sense to me.

 

1. How can you check to see if two keys are pressed at the same time? 

 

2. What does the BAND operator do? When looking at examples of working with controller inputs (such as the example below) I see the BAND operator in use but it is not clear to me what it does and trying to Google it hasn't returned anything of note.

 

pad1=jsfGetPad(1)	
IF (pad1 BAND JAGPAD_LEFT AND viewportx>0) THEN									' If we can move left then update viewport pointer and redraw the map
        viewportx--
        framecounter=0
        refreshmap = 1																' Set flag to request map is updated
ELSEIF (pad1 BAND JAGPAD_RIGHT AND (viewportx+viewportmaxx)<mapsize-1) THEN
        viewportx++
        framecounter=0
        refreshmap = 1																' Set flag to request map is updated
ENDIF

 

3. Is it possible to have two distinct sprite layers for text? The examples I see have one layer. It seems simple enough to add another to rapinit.s but its not clear to me how I would select between the two when programming.

 

4. Is it possible to physically rotate a sprite on screen?

 

To anyone with the time to answer thank you in advance. My apologies if these are very basic questions (no pun intended).

Link to comment
Share on other sites

3. Even if this is possible (I don’t think it is, though I haven’t personally tried) I would highly advise against it as the text layer is a performance hog in my personal experience. Not sure what benefit that would give you but would like to hear what you’re going for. 
 

4. Unless hidden, as far as I’m aware of, there are no functions implemented to rotate sprites. The reason given because it’s slow and as with scaling sprites, I imagine would introduce similar performance issues. 

  • Like 1
Link to comment
Share on other sites

8 minutes ago, Clint Thompson said:

3. Even if this is possible (I don’t think it is, though I haven’t personally tried) I would highly advise against it as the text layer is a performance hog in my personal experience. Not sure what benefit that would give you but would like to hear what you’re going for. 
 

4. Unless hidden, as far as I’m aware of, there are no functions implemented to rotate sprites. The reason given because it’s slow and as with scaling sprites, I imagine would introduce similar performance issues. 

Thank you!

Link to comment
Share on other sites

1 hour ago, Clint Thompson said:

3. Even if this is possible (I don’t think it is, though I haven’t personally tried) I would highly advise against it as the text layer is a performance hog in my personal experience. Not sure what benefit that would give you but would like to hear what you’re going for. 
 

4. Unless hidden, as far as I’m aware of, there are no functions implemented to rotate sprites. The reason given because it’s slow and as with scaling sprites, I imagine would introduce similar performance issues. 

Regarding the third question, I'm interested in having scrolling text while also having some text fixed in place.

Link to comment
Share on other sites

8 minutes ago, Gedalya said:

Regarding the third question, I'm interested in having scrolling text while also having some text fixed in place.

 

Split the text layer object into two or more smaller ones. Then you can overlay parts of it where you need.

  • Like 1
Link to comment
Share on other sites

1 hour ago, CyranoJ said:

 

Split the text layer object into two or more smaller ones. Then you can overlay parts of it where you need.

Thank you! So basically I can add in a few smaller layers which each take up a portion of the screen, lets say two which each take up a half of the screen. Is that right? Then the text automagically is assigned to the correct layer based on where rapLocate is directed?

Link to comment
Share on other sites

6 hours ago, Gedalya said:

Anyone know how to check if two keys are pressed at the same time? An example being the d-pad, up and left at the same time, et. al..

Pad1 band (up bor left) = (up bor left)

( Assuming band means binary and and analogous bor means binary or)

  • Like 1
Link to comment
Share on other sites

Posted (edited)
11 hours ago, 42bs said:

Pad1 band (up bor left) = (up bor left)

( Assuming band means binary and and analogous bor means binary or)

This is what I have:

if pad1=JAGPAD_UP then
		sprite[shippointer].y_ = sprite[shippointer].y_-3
elseif pad1 BAND (JAGPAD_UP BOR JAGPAD_LEFT) = (JAGPAD_UP BOR JAGPAD_LEFT) then
		sprite[shippointer].y_ = sprite[shippointer].y_-3
		sprite[shippointer].x_ = sprite[shippointer].x_-3
elseif pad1 BAND (JAGPAD_UP BOR JAGPAD_RIGHT) = (JAGPAD_UP BOR JAGPAD_RIGHT) then
		sprite[shippointer].y_ = sprite[shippointer].y_-3
		sprite[shippointer].x_ = sprite[shippointer].x_+3

 

The code is intended to change the position of a sprite on screen. It is intended to recognize Up, Up & Left, and Up & Right. In practice though it only recognizes Up, and Up & Left; Up & Right is simply interpreted as Up & Left for some reason.

Edited by Gedalya
Link to comment
Share on other sites

Looking at your code snippet I dont think you are asking the right question.

 

If you want to move the sprite up, down, left, right do them independently.  Doing them independently means they can be done in conjunction.

 

Pseudocode:

 

If(pad & JAGPAD_UP)

  y += 3

If(pad & JAGPAD_LEFT)

  x -= 3

If(pad & JAGPAD_RIGHT)

  x += 3

  • Like 3
Link to comment
Share on other sites

2 hours ago, Gedalya said:

This is what I have:

if pad1=JAGPAD_UP then
		sprite[shippointer].y_ = sprite[shippointer].y_-3
elseif pad1 BAND (JAGPAD_UP BOR JAGPAD_LEFT) = (JAGPAD_UP BOR JAGPAD_LEFT) then
		sprite[shippointer].y_ = sprite[shippointer].y_-3
		sprite[shippointer].x_ = sprite[shippointer].x_-3
elseif pad1 BAND (JAGPAD_UP BOR JAGPAD_RIGHT) = (JAGPAD_UP BOR JAGPAD_RIGHT) then
		sprite[shippointer].y_ = sprite[shippointer].y_-3
		sprite[shippointer].x_ = sprite[shippointer].x_+3

 

The code is intended to change the position of a sprite on screen. It is intended to recognize Up, Up & Left, and Up & Right. In practice though it only recognizes Up, and Up & Left; Up & Right is simply interpreted as Up & Left for some reason.

Seems you start coding, right? 

If you first test a single bit, the test for two bits is never done.

But go for OVERiDE's solution.

  • Like 1
Link to comment
Share on other sites

5 hours ago, OVERRiDE said:

Looking at your code snippet I dont think you are asking the right question.

 

If you want to move the sprite up, down, left, right do them independently.  Doing them independently means they can be done in conjunction.

 

Pseudocode:

 

If(pad & JAGPAD_UP)

  y += 3

If(pad & JAGPAD_LEFT)

  x -= 3

If(pad & JAGPAD_RIGHT)

  x += 3

This worked thank you!

Link to comment
Share on other sites

35 minutes ago, Gedalya said:

The last thing I'm trying to do rotate an image back and forth on screen depending on input from the d-pad. Reading @Clint Thompson's response above it seems that there isn't an easy way to do that. In practice would something like that simply be a form of animation? An animated sprite I mean.

Yes, create the rotations in a sprite and either animate it or manually change to the rotation frame graphic you require.

  • Like 4
Link to comment
Share on other sites

How can I set music to loop instead of playing once?

 

My entry in rapu235.s looks like this:

 

sample0:	dc.l	gamemusic1		; start of sample
			dc.l	gamemusic1_end	; end of sample
			dc.l	0				; repeat offset
			dc.l	0				; repeat length
			dc.w	0				; <NULL>
			dc.b	0				; fine tune
s0_vol:	dc.b	192					; volume
			dc.l	8000			; default play rate

 

I presume tweaking the repeat offset or repeat length would do the trick, however I am not sure what values to put.

 

Link to comment
Share on other sites

On 10/8/2023 at 3:28 PM, CyranoJ said:

Repeat offset: start of sample

Reapeat length: size of sample

 

Polite tease: There is a manual, you know 😀

Thank you for clarfying! Also sorry for all of the questions. I've been really enjoying working with the Jag; its surprisingly easy to pick up and quite rewarding to see my work on screen!

  • Like 3
Link to comment
Share on other sites

I have a sub routine which handles collision for three objects; when it detects the collision it displays an explosion animation and plays an explosion sound. When I run the code the sound works fine on each collision as expected; however, the explosion animation only appears to play once on the first collision, and then on the subsequent collisions I basically see only the first frame. Is there something I need to do to reset the animation or something else I'm overlooking? 

 

globalCollision = rapCollide(ID_shipa, ID_shipd_down, ID_astbiga, ID_astbigc)
if globalCollision > -1 then
	FOR i = 0 TO 2
		if sprite[ID_astbiga+i].was_hit = 1 then
			sprite[ID_explosions].active = R_is_active
			sprite[ID_explosions].x_ = sprite[ID_astbiga+i].x_ + sprite[ID_astbiga+i].width/2
			sprite[ID_explosions].y_ = sprite[ID_astbiga+i].y_ + sprite[ID_astbiga+i].height/2
			jsfLoadClut(strptr(EXPLOSIONS_clut),8,16)			
				
			u235PlaySampleFreq(2,ID_explosion,8000)
				
			sprite[ID_astbiga+i].active = R_is_inactive
			sprite[ID_astbiga+i].was_hit = -1
		end if	
	NEXT
end if

 

Link to comment
Share on other sites

1 hour ago, Gedalya said:

I have a sub routine which handles collision for three objects; when it detects the collision it displays an explosion animation and plays an explosion sound. When I run the code the sound works fine on each collision as expected; however, the explosion animation only appears to play once on the first collision, and then on the subsequent collisions I basically see only the first frame. Is there something I need to do to reset the animation or something else I'm overlooking? 

 

globalCollision = rapCollide(ID_shipa, ID_shipd_down, ID_astbiga, ID_astbigc)
if globalCollision > -1 then
	FOR i = 0 TO 2
		if sprite[ID_astbiga+i].was_hit = 1 then
			sprite[ID_explosions].active = R_is_active
			sprite[ID_explosions].x_ = sprite[ID_astbiga+i].x_ + sprite[ID_astbiga+i].width/2
			sprite[ID_explosions].y_ = sprite[ID_astbiga+i].y_ + sprite[ID_astbiga+i].height/2
			jsfLoadClut(strptr(EXPLOSIONS_clut),8,16)			
				
			u235PlaySampleFreq(2,ID_explosion,8000)
				
			sprite[ID_astbiga+i].active = R_is_inactive
			sprite[ID_astbiga+i].was_hit = -1
		end if	
	NEXT
end if

 

 

You need to set sprite_curframe to the last (first? bottom!) frame of animation as well, as it will be at zero from the previous run.

Link to comment
Share on other sites

2 hours ago, SlidellMan said:

I'd like to see a playable demo from you, Gedalya.

Thank you! I will put something together to share! I will need a little time though to make it at least playable; perhaps by months end. I've been having quite a bit of fun. There is some excellent sources of inspiration here in the forums! I just got a Skunk Board so seeing my creation come to life on an actual Jag is a thrill!

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...