DSiWare Forum

Topic: Petit Computer

Showing 1,521 to 1,540 of 9,534

AuthorMessage
Avatar

damolii

1,521. Posted:

@ramstrong ..... thank you anyway for your other advice. I guess I will have to find the answer myself. Thank you again. You have made it easier to do this.

I don't have a 3DS so what do I put here? -Damolii

AuthorMessage
Avatar

ZombieChiggers

1,522. Posted:

hey morphtroid. please make more games they are just awesom and i also could use some help with sprite,read,and data commands. you are just a boss at those commands so please

Edited on by ZombieChiggers

Cameron Stover VVVVVVVVVVVVVV ALSO VVVVVVVV and i like trains (BOOM!) also minecraft and trollface!
INFECTED. NEW ZOMBIE

3DS Friend Code: 4854-7026-5042

AuthorMessage
Avatar

Bluerobin2

1,523. Posted:

Untitled

You want one of these right? :)

I just need some feedback. Plus mainly it is a Petit computer journal.

Edited on by Bluerobin2

Everybody do a chirp. CHIRP.

Blog: bluerobin2.blogspot.com
Backloggery: backloggery.com/bluerobin2

3DS Friend Code: 3007-9228-5126

AuthorMessage
Avatar

Morpheel

1,524. Posted:

snoremac wrote:

hey morphtroid. please make more games they are just awesom and i also could use some help with sprite,read,and data commands. you are just a boss at those commands so please

I'm slowly working on that :D Thank you.

About Sprite, Read and Data, I have written something about them in the tutorials thread. It's somewhere in my long post.

Oops, no username pun.

Oh look! A Morphloggery.
Oh! eShop Gurus.

3DS Friend Code: 0173-1330-0080 | Nintendo Network ID: Abgarok

AuthorMessage
Avatar

ZombieChiggers

1,525. Posted:

ok didnt know

Cameron Stover VVVVVVVVVVVVVV ALSO VVVVVVVV and i like trains (BOOM!) also minecraft and trollface!
INFECTED. NEW ZOMBIE

3DS Friend Code: 4854-7026-5042

AuthorMessage
Avatar

Credible

1,526. Posted:

I need some help with my program. I'm trying to have a blast sprite collide with a skeleton sprite and destroy it. When I use SPHITSP(1,2) (skeleton and blast sprite, respectively) I get an Illegal Function Call. I am sure this is due to the blast sprite not being created when the code is reached, as the player needs to press the a button to create it. So, I tried putting it inside the blast sprite's gosub, but it seems to ignore it entirely. Here's a basic version of what I'm trying to do:
When the player presses A:
@BLASTUP
SPSET 2,236,8,0,0,0
SPANGLE 2,270,0,1
SPANIM 2,4,5,1
SPOFS 2,X,Y,0
BEEP 1
IF SPHITSP(1,2)==TRUE THEN GOSUB @SDED: 'Skeleton death animation
WAIT 20
SPCLR 2
RETURN

Edited on by Credible

Credible

AuthorMessage
Avatar

Morpheel

1,527. Posted:

Why don't you try to have the explosion sprite created from the very begining of the program and hide it from the player's view (outside the screen).
Then you can move it back and forth from it's hiding place when it's needed instead of resetting it every time.

Oops, no username pun.

Oh look! A Morphloggery.
Oh! eShop Gurus.

3DS Friend Code: 0173-1330-0080 | Nintendo Network ID: Abgarok

AuthorMessage
Avatar

Credible

1,528. Posted:

I actually have thought of that Morphtroid, and I remember it not working, but I'll try and implement it again and if it works then I'll post the code I made for that.
Also, good work on Petit Farm. Looking at your code for it has helped me through some other errors I had.

Edited on by Credible

Credible

AuthorMessage
Avatar

Credible

1,529. Posted:

Alright, I've figured it out! Unfortunately, it only causes more problems.
Anyway, what I've come to see is that I don't even need to have the blast hidden, or even created from the start. When I put the command SPHITSP(1,2) in the blast gosub, I wasn't seeing any reactions. This is because I have the blast sprite rotated 270 degrees so it animates upwards, and thus the collision detection coordinates for that sprite are at the bottom left of it. I had already set up the player's collision with the skeleton (which blew up the player and set it back to the starting coordinates), so I couldn't have gotten close enough to have known that the blast's collision was where it was. I turned off the player collision and tried again, and the skeleton blew up. So I guess I need to set a collision box around the blast sprite, instead of only having the lower left pixel affect anything.

However, now that the skeleton blows up (and then clears it's existence) I get another error stating that the skeleton doesn't exist (such as when the program goes back to the loop and then tries to animate it.) My temporary solution to this is to move the skeleton offscreen after its death animation instead of clearing it. I'm sure that if I move some gosubs around, it will work as normal.

Edited on by Credible

Credible

AuthorMessage
Avatar

Morpheel

1,530. Posted:

Thank you about your previous comment :D

I was gonna to comment about the collision area before too, but I figured you would be using a normal 16*16 unrotated sprite :P Well, I'm glad you sorted that part out! About that other bit...
Never understimate the power of hiding things from the player instead of destroying them.
If you're gonna use it again, then why bother clearing it at all?

Oops, no username pun.

Oh look! A Morphloggery.
Oh! eShop Gurus.

3DS Friend Code: 0173-1330-0080 | Nintendo Network ID: Abgarok

AuthorMessage
Avatar

Credible

1,531. Posted:

The sprite I'm using is a standard sprite (Numbers 236 -239 for animation.) I had to rotate the sprite because that particular sprite faces and animates to the right, and depending on which way the player faces is which way the sprite faces.

The only problem I could see with hiding sprites is slowdown, but maybe that's only when there are a ton of sprites being displayed on screen.

Edited on by Credible

Credible

AuthorMessage
Avatar

Hairmanban19

1,532. Posted:

@swordx If you are still checking this thread when do think you will be finished with dungeon adventure,i really can not wait for it.

...

3DS Friend Code: 3136-7615-5907

AuthorMessage
Avatar

swordx

1,533. Posted:

@Hairmanban19 Check the QR code thread for your answer. Thanks for the support, I really appreciate it!

swordx

AuthorMessage
Avatar

Credible

1,534. Posted:

Well, I fixed another one of my program's problems! A word of advice for everyone: beware of rotating your sprites!
When I first tried to set the collision detection box on my blast sprite, it wasn't working. I tried doing this:
@BLASTUP
SPSET 2,236,8,0,0,0
SPANGLE 2,270,0,1
SPANIM 2,4,5,1
SPOFS 2,X,Y,0
SPCOL 2,0,0,16,16,0
IF SPHITSP(1,2) THEN SPCLR 2:GOSUB @SDED
(leaving some code out)

This didn't work because the sprite was rotated, and so the coordinates I set in SPCOL would be correct, except it ended up setting a box made of 16x16 pixels BELOW where the sprite is, starting from the bottom left corner of the sprite. So I set the starting coordinates to this:
SPCOL 2,-16,-16,16,16,0
And it works fine now.

Edited on by Credible

Credible

AuthorMessage
Avatar

Discostew

1,535. Posted:

Credible wrote:

Well, I fixed another one of my program's problems! A word of advice for everyone: beware of rotating your sprites!
When I first tried to set the collision detection box on my blast sprite, it wasn't working. I tried doing this:
@BLASTUP
SPSET 2,236,8,0,0,0
SPANGLE 2,270,0,1
SPANIM 2,4,5,1
SPOFS 2,X,Y,0
SPCOL 2,0,0,16,16,0
IF SPHITSP(1,2) THEN SPCLR 2:GOSUB @SDED
(leaving some code out)

This didn't work because the sprite was rotated, and so the coordinates I set in SPCOL would be correct, except it ended up setting a box made of 16x16 pixels BELOW where the sprite is, starting from the bottom left corner of the sprite. So I set the starting coordinates to this:
SPCOL 2,-16,-16,16,16,0
And it works fine now.

The reason is because the sprite's point of origin (also point of rotation) is at the default (0,0) of the sprite, or top-left corner. When you rotates by 270 degrees clockwise, it rotated on that point, so you're left with the sprite on it's side, but 16 pixels above the original position (sprites set without using optional width/height at defaulted to 16x16). This also means that the collision box you set will also be 16 pixels below the sprite. There is a fix to this.

SPHOME control_number (0~99), x, y

This will change the point of origin, and will also change the sprite's point of rotation to match. In your example, try using...

SPHOME 2,8,8

...which should now center on your sprite, and any rotations you make will not left it drift off by the corner anymore. Just to note, it will also offset your sprite by the negative of the values you set, so if you had your 16x16 sprite set with (8,8) with SPHOME, it will shift your sprite to the left by 8 and up by 8. Since it shifts the entire sprite, you'll also have to compensate with SPCOL by that much, negatively.

Edited on by Discostew

"What fun is there in making sense?"
Lazer Light Studios - Home of the MM2 PTC project

Pokemon 3DS Friend Safari - Ice - Spheal, Sneasel, Lapras

3DS Friend Code: 4425-1477-0127 | Nintendo Network ID: Discostew

AuthorMessage
Avatar

ramstrong

1,536. Posted:

Credible wrote:

I need some help with my program. I'm trying to have a blast sprite collide with a skeleton sprite and destroy it. When I use SPHITSP(1,2) (skeleton and blast sprite, respectively) I get an Illegal Function Call. I am sure this is due to the blast sprite not being created when the code is reached, as the player needs to press the a button to create it. So, I tried putting it inside the blast sprite's gosub, but it seems to ignore it entirely. Here's a basic version of what I'm trying to do:
When the player presses A:
@BLASTUP
SPSET 2,236,8,0,0,0
SPANGLE 2,270,0,1
SPANIM 2,4,5,1
SPOFS 2,X,Y,0
BEEP 1
IF SPHITSP(1,2)==TRUE THEN GOSUB @SDED: 'Skeleton death animation
WAIT 20
SPCLR 2
RETURN

Now, that is how you ask a question! Very clear question. I see that Morphtroid and Discostew has answered your questions. Also take a look at my Asteroid program to see sprites in action. In my experience, 99 sprites doesn't slow you down at all. It can take a while for you to process them all, though, but absolutely no problem displaying them. Also, although hiding the sprites is the recommended method, you actually can create sprites on the fly. You just have to keep track of it manually.

'Create sprite
SPSET 2,236,8,0,0,0
SP[2]=1

'Check sprite
IF SP[2]==1 THEN IF SPHITSP(1,2)==TRUE THEN GOSUB @SDED: 'Skeleton death animation

'Destroy sprite
SP[2]=0
SPCLR 2

Petit Computer Journal
Old site http://ramstrong.blogspot.com

Let's just call a spade, a spade.

3DS Friend Code: 1091-7596-4855

AuthorMessage
Avatar

Bluerobin2

1,537. Posted:

@credible what kind of game are you making? So far this is mysteriously sounding like something from my battlewood game... Oh yeah and welcome to nintendo life and this forum. Unless of course you had a previous account :D. It is very nice to meet yet another person who appreciates programming and Petit computer. Good to see you. :)

Edited on by Bluerobin2

Everybody do a chirp. CHIRP.

Blog: bluerobin2.blogspot.com
Backloggery: backloggery.com/bluerobin2

3DS Friend Code: 3007-9228-5126

AuthorMessage
Avatar

Credible

1,538. Posted:

bluerobin2 wrote:

@credible what kind of game are you making? So far this is mysteriously sounding like something from my battlewood game...

I'd rather not say, only because it's not that far in to development. I do have a clear idea of what I want the game to be though, but it's not an RPG like your Battlewood game.

Credible

AuthorMessage
Avatar

Credible

1,539. Posted:

I need some more help. I have an array with dimensions of 16 and 12 (DIM 16,12). In this array, Walls are assigned W and open spaces are assigned 0.
I also have a small arrow sprite (SPSET 0,1,0,0,0,0) that moves with the Directional Pad. When this sprite touches a W, I need it to not be able to proceed. You know, just like walls in real life. Here's an example of the code I'm using:
CLS:CLEAR
RESTORE @MAPDATA
DIM MAP(6,6)
FOR X=0 TO 6
FOR Y=0 TO 6
READ MAP(X,Y)
NEXT
NEXT
FOR X=0 TO 5
FOR Y=0 TO 5
LOCATE X,Y
IF MAP(X,Y)==0 THEN LOCATE X,Y:? "0"
IF MAP(X,Y)==1 THEN LOCATE X,Y:? "W"
NEXT
NEXT
SPSET 0,1,0,0,0,0
@LOOP
SPOFS 0,X,Y
'D Pad controls stuff here, leaving it out
VSYNC 1:GOTO @LOOP

@MAPDATA
DATA 1,1,1,1,1,1
DATA 1,0,0,0,0,1
DATA 1,0,0,0,0,1
DATA 1,0,0,0,0,1
DATA 1,0,0,0,0,1
DATA 1,1,1,1,1,1

This creates a small room with the arrow sprite in it. So how do I make it stop at collisions with W's?

Edited on by Credible

Credible

AuthorMessage
Avatar

petiSnail

1,540. Posted:

Credible wrote:

I need some more help. I have an array with dimensions of 16 and 12 (DIM 16,12). In this array, Walls are assigned W and open spaces are assigned 0.
I also have a small arrow sprite (SPSET 0,1,0,0,0,0) that moves with the Directional Pad. When this sprite touches a W, I need it to not be able to proceed. You know, just like walls in real life. Here's an example of the code I'm using:
CLS:CLEAR
RESTORE @MAPDATA
DIM MAP(6,6)
FOR X=0 TO 6
FOR Y=0 TO 6
READ MAP(X,Y)
NEXT
NEXT
FOR X=0 TO 5
FOR Y=0 TO 5
LOCATE X,Y
IF MAP(X,Y)==0 THEN LOCATE X,Y:? "0"
IF MAP(X,Y)==1 THEN LOCATE X,Y:? "W"
NEXT
NEXT
SPSET 0,1,0,0,0,0
@LOOP
SPOFS 0,X,Y
'D Pad controls stuff here, leaving it out
VSYNC 1:GOTO @LOOP

@MAPDATA
DATA 1,1,1,1,1,1,1
DATA 1,0,0,0,0,0,1
DATA 1,0,0,0,0,0,1
DATA 1,0,0,0,0,0,1
DATA 1,0,0,0,0,0,1
DATA 1,1,1,1,1,1,1

This creates a small room with the arrow sprite in it. So how do I make it stop at collisions with W's?

I don't know, but one thing I can tell you is that the size of your array declaration (6x6) is different from the nested loop (7x7)* and the DATA (7x6). They need to be the same before you can get desirable results. Also, make the outer loop of the nested loop Y and the inner one X.

As for the collision logic, I think the idea is to test the area ahead for a wall before proceeding.
Something like :
IF (BUTTON(2) AND 8) AND MAP (X+1,Y) != 1 THEN PLAYERX=PLAYERX+1

*not a typo, FOR X=0 TO 6 is inclusive so it has needs 7 elements in an array (DIM MAP(7,7)

Edited on by petiSnail

petiSnail