Forums

Topic: Petit Computer

Posts 7,281 to 7,300 of 9,620

Gimmemorecoinz

Leviceljir wrote:

I dunno why but shooting in my games being bad :/. Its moving the character with the bullet
heres some of the code:

@MOVE
B=BUTTON()
IF B AND 1 THEN GOSUB @UP
IF B AND 2 THEN GOSUB @DOWN
IF B AND 32 THEN GOSUB @ SHOOT
IF SHOOT==1 THEN GOSUB @MOVEBULLET
GOTO @MOVE

@UP
VSYNC 1
SPSET 0,0,0,0,0,0
SPSCALE 0,200,0
SPHOME 0,0,0
SPSET 1,1,0,0,0,0
SPSCALE 1,200,0
SPHOME 1,-8,0
SPOFS 0,X,Y,0
SPOFS 1,X,Y,0
Y=Y-1
RETURN

@DOWN
VSYNC 1
SPSET 0,0,0,0,0,0
SPSCALE 0,200,0
SPHOME 0,0,0
SPSET 1,1,0,0,0,0
SPSCALE 1,200,0
SPHOME 1,-8,0
SPOFS 0,X,Y,0
SPOFS 1,X,Y,0
Y=Y+1
RETURN

@SHOOT
SHOOT=1
RETURN

@MOVEBULLET
SPSET 3,2,0,0,0,0
SPOFS 3,X,Y,0
X=X+1
IF X>200 THEN SPCLR 3
RETURN

why is it doing this? can anybody fix this code so it works?

Took a quick look. Her'es what you're doing wrong!
Your using X for the bullet, and up there your using X for the player.
So here in your @bullet when you do X=X+1
then up there when you do SPOFS 0,X,Y,0
SPOFS 1,X,Y,0
Your telling it to use the SAME value as the bullet for the player.
You can't do this..
Petit computer interprets X=X+1 and Spofs 0, X, Y, 0
and Spofs 1, X, Y, 0
as "put this sprite at X, Y"
X is a static value til you change it so is Y
You should do this instead...

In bullet do this
@MOVEBULLET
SPSET 3,2,0,0,0,0
SPOFS 3,Bullet_X,Bullet_Y,0
Bullet_X=Bullet_X+1
IF Bullet_X>200 THEN SPCLR 3
RETURN

now your bullet routine wont move the player.
I hope this helps. :3

Got a project? PM ME on here!
Youtube: lostkitty64x
Want help with coding? PM ME! PM ME PM ME!! XD
FC: WIll post later.
Systems I own: ds lite, 3DS, PC/gaming, steam platform. I play alot of games. Just ask ! Minecraft anyone? :D

Discostew

@Leviceljir You're using "X" and "Y" for both the character and the bullet. You need to give them their own position variables.

Discostew

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

LeviCelJir

Thanks gimme and discostew but now the bullet doesn't spawn where the player is when i shoot it.
how do i fix that

Hi I'm Levi and I like Bloopys :^)

Gimmemorecoinz

Discostew wrote:

@Leviceljir You're using "X" and "Y" for both the character and the bullet. You need to give them their own position variables.

hey discostew can you help me create a map editor for ptc for my code generation project?
I know how map editors work but what I need help with is the whole bgoffset vs the current tile and that sort of stuff
the ptc specific part is what' I'm stuck on right now. I want to do animated tiles and also check the background tiles against specific values.
I'm going to need to check alot of different values, i've read your tutorials but I'm still lost because you didn't cover most of the advanced things like, updating one specific tile on the map or cycling an animated tile. Or checking tiles based on their BG number.
It's not that hard but I could use a few tips and advice , maybe some simple examples showing how I might implement that? not full code just like partically complete subroutines to express the concept.

Got a project? PM ME on here!
Youtube: lostkitty64x
Want help with coding? PM ME! PM ME PM ME!! XD
FC: WIll post later.
Systems I own: ds lite, 3DS, PC/gaming, steam platform. I play alot of games. Just ask ! Minecraft anyone? :D

Gimmemorecoinz

Leviceljir wrote:

Thanks gimme and discostew but now the bullet doesn't spawn where the player is when i shoot it.
how do i fix that

in your code at the very start of the game do this
bullet_active=false

@MOVEBULLET
SPSET 3,2,0,0,0,0
SPOFS 3,Bullet_X,Bullet_Y,0
Bullet_X=Bullet_X+1
IF Bullet_X>200 THEN SPCLR 3
IF Bullet_X>200 then Bullet_active=false
RETURN

@Shoot
if bullet_active==false then Bullet_X=X and Bullet_Y=Y
bullet_active=true
shoot=1
return

Edited on by Gimmemorecoinz

Got a project? PM ME on here!
Youtube: lostkitty64x
Want help with coding? PM ME! PM ME PM ME!! XD
FC: WIll post later.
Systems I own: ds lite, 3DS, PC/gaming, steam platform. I play alot of games. Just ask ! Minecraft anyone? :D

LeviCelJir

@gimmemorecoinz
syntax error (116)
166:if bullet_active==false then Bullet_X=X and Bullet_Y=Y

Hi I'm Levi and I like Bloopys :^)

Malltog

Leviceljir wrote:

@gimmemorecoinz
syntax error (116)
166:if bullet_active==false then Bullet_X=X and Bullet_Y=Y

IF SHOOT==0 THEN BULLETX=X : BULLETY=Y
replace all the references to say Bullet_X and use SHOOT instead of bulletactive. Why waste variables?

And how do I make or use custom sprites?
Sorry if it's in the manual. I'm kinda busy now and can't check it but can post here.

Edited on by Malltog

Malltog

Nintendo Network ID: Malltog

Gimmemorecoinz

Malltog wrote:

Leviceljir wrote:

@gimmemorecoinz
syntax error (116)
166:if bullet_active==false then Bullet_X=X and Bullet_Y=Y

IF SHOOT==0 THEN BULLETX=X : BULLETY=Y
replace all the references to say Bullet_X and use SHOOT instead of bulletactive. Why waste variables?

And how do I make or use custom sprites?
Sorry if it's in the manual. I'm kinda busy now and can't check it but can post here.

because...
the line of code that's here:
if bullet_active==false then Bullet_X=X and Bullet_Y=Y
was originally inside @Bullet
which meant that it would have set the bullet X and Y to the players X and Y each loop if it was this.
if shoot==false then Bullet_X=X and Bullet_Y=Y
Furthermore shoot would never be false within @bullet
But then I realized bullet_active would never be false within that loop. anyways.

So I moved it to @Shoot and kept the original formatting for convenience sake.
also seperating whether the player has shot a bullet and whether the bullet itself is active is just good coding practice.
They are two seperate properties of the game state. so they should be seperated! and there's no such thing as a wasted variable when it comes to good design.

you can further improve the code by putting this line of code inside of @shoot

if bullet_active=true then return 'this makes it so the bullet doesn't get positioned, or spawned until AFTER the one that's on the screen is gone (even if you press the button again!)

Edited on by Gimmemorecoinz

Got a project? PM ME on here!
Youtube: lostkitty64x
Want help with coding? PM ME! PM ME PM ME!! XD
FC: WIll post later.
Systems I own: ds lite, 3DS, PC/gaming, steam platform. I play alot of games. Just ask ! Minecraft anyone? :D

Malltog

Malltog wrote:

Leviceljir wrote:

@gimmemorecoinz
syntax error (116)
166:if bullet_active==false then Bullet_X=X and Bullet_Y=Y

IF SHOOT==0 THEN BULLETX=X : BULLETY=Y
replace all the references to say Bullet_X and use SHOOT instead of bulletactive. Why waste variables?

And how do I make or use custom sprites?
Sorry if it's in the manual. I'm kinda busy now and can't check it but can post here.

Please?
I need it for my... Drumroll please... 2D Minecraft (-like thing, called Beta)

Malltog

Nintendo Network ID: Malltog

InsertPi

Ran a speed test on SimpleC v1.2. My code:

SETV VAR[L]=0
SETV VAR[1]=1
LOOP:
MATH L=L+1
OUT<VAR[L]
OUT<"\n"
GOTO LOOP

This code gets 100 cycles per second!!! The equilavant code in SmileBASIC is:

L=0
@LOOP
L=L+1
PRINT L
GOTO @LOOP

And just for funzies, here's the equilavant in C++:

#include <iostream>
int main(void)
{
loop:
l=l+1;
cout<< l <<"\n";
goto loop;
}

Edited on by InsertPi

If Facebook, Myspace, Twitter, Instagram, and Snapchat were all destroyed, 90% of teens would go insane. If you're one of the 10% that would be laughing at them, copy & paste this into your signature and hope it happens.

3DS Friend Code: 2148-9259-0831 | Nintendo Network ID: IAmAPerson620 | Twitter:

Arn0ld

[quote=IAmAPerson]Ran a speed test on SimpleC v1.2. My code:

SETV VAR[L]=0
SETV VAR[1]=1
LOOP:
MATH L=L+1
OUT<VAR[L]
OUT<"n"
GOTO LOOP

This code gets 100 cycles per second!!! The equilavant code in SmileBASIC is:

L=0
@LOOP
L=L+1
PRINT L
GOTO @LOOP

And just for funzies, here's the equilavant in C++:

#include <iostream>
int main(void)
{
loop:
l=l+1;
cout<< l <<"n";
goto loop;
}

</blockquote>
I have a quick question why do you have to set a variable for the number one?
(And does anyone know how to have multiple goto loops at once?)

Botw > OoT

3DS Friend Code: 0748-4970-2550 | Nintendo Network ID: Xjarnold

InsertPi

@Xtremetdifan because MATH can't tell the difference between a constant and a variable, so it treats 1 as VAR[1]. Because of that, I assign a value of 1 to VAR[1]. Then it works how I want it to. NOTE: THIS IS A LOW-LEVEL LANGUAGE! It is fast but hard to use!

If Facebook, Myspace, Twitter, Instagram, and Snapchat were all destroyed, 90% of teens would go insane. If you're one of the 10% that would be laughing at them, copy & paste this into your signature and hope it happens.

3DS Friend Code: 2148-9259-0831 | Nintendo Network ID: IAmAPerson620 | Twitter:

TAINT_Zzyex

what does r1 do in mml?

"Did somebody say Aincrad?"
"No, go back to your own game!"
"awwww"
"And make out with Asuna."
"Aww-I mean YAY"

Twitter:

InsertPi

TAINT_Zzyex wrote:

what does r1 do in mml?

Rests for 1 beat

If Facebook, Myspace, Twitter, Instagram, and Snapchat were all destroyed, 90% of teens would go insane. If you're one of the 10% that would be laughing at them, copy & paste this into your signature and hope it happens.

3DS Friend Code: 2148-9259-0831 | Nintendo Network ID: IAmAPerson620 | Twitter:

calc84maniac

TAINT_Zzyex wrote:

what does r1 do in mml?

It rests for the length of a whole note (four quarter notes).

calc84maniac

Arn0ld

IAmAPerson wrote:

@Xtremetdifan because MATH can't tell the difference between a constant and a variable, so it treats 1 as VAR[1]. Because of that, I assign a value of 1 to VAR[1]. Then it works how I want it to. NOTE: THIS IS A LOW-LEVEL LANGUAGE! It is fast but hard to use!

Hm. Interesting...I'm quite intrigued of how that will work on large scale projects, it still looks amazing and is amazing that you've made a custom programming language! low-level or not.

Botw > OoT

3DS Friend Code: 0748-4970-2550 | Nintendo Network ID: Xjarnold

UltraWolf2X

@JLMan Cool! Please work on it right now!

Herpa-Derp Derp!!!
My 3DS Friend Code: 3609-1380-2642

InsertPi

I hope you guys are happy! SimpleC programs can now be up to 1000 lines! Long enough? I will soon be making a fun little game with objects.
I also added the STOP command. It terminates the program. Done. Ends it. This is because: when you finish a program, it takes a bit of time for the interpreter to read the rest of the code (even though there's nothing there), since there are now 1000 available lines. So using STOP sends it to the end of the code.

Edited on by InsertPi

If Facebook, Myspace, Twitter, Instagram, and Snapchat were all destroyed, 90% of teens would go insane. If you're one of the 10% that would be laughing at them, copy & paste this into your signature and hope it happens.

3DS Friend Code: 2148-9259-0831 | Nintendo Network ID: IAmAPerson620 | Twitter:

Ralph

IAmAPerson wrote:

And just for funzies, here's the equilavant in C++:

#include <iostream>
int main(void)
{
loop:
l=l+1;
cout<< l <<"n";
goto loop;
}

Why are you using goto like that in C++?

Edited on by Ralph

Ralph

InsertPi

@Ralph that's how I was taught. Is there another/better way to do it?
Ok no more off topic for me.
I am ECSTATIC to see how much I can make in SimpleC now that I have 1000 lines to work with!

If Facebook, Myspace, Twitter, Instagram, and Snapchat were all destroyed, 90% of teens would go insane. If you're one of the 10% that would be laughing at them, copy & paste this into your signature and hope it happens.

3DS Friend Code: 2148-9259-0831 | Nintendo Network ID: IAmAPerson620 | Twitter:

Please login or sign up to reply to this topic