Log In  


same as title, its trying to call player1 but isnt able to?
im relatively new to coding so idrk how to fix this

1


Can you post the code? It's hard to help without it.


apologies, i thought i uplaoded the png file?
heres the cart
edit: so far i have only done the "throw" part in the menu, thats where the error is

Cart #fudagonitu-0 | 2024-08-09 | Code ▽ | Embed ▽ | No License


1) You're calling init_game() after the 2 spr() calls. You'll want to move it before them.
2) In line 45, tab 6, you have typed "player" instead of "player1"

This stops it from erroring at least, but I'm not sure if there are any other bugs.


I'm new to programming and pico-8, but as i watched tutorials about gamestates...

the _init() is missing. You have a game_init(), that's not called, so player{} is never set.

Nice comments in your code, liked that on tab0.


ah no I can't take credit for that Zellente! I downloaded it from KQl1N, the comments are just there to help me.

Appreciate the help as always, Soupster! should be able to see if it works later.


@Zellente init_game() is called in _update(), but I'm not sure whether it's being called everu frame or not.


Ah Soupster, yes I did'nt see init_game() there (or same place in function throwgame tab1)

But is an init called more than once? And can you move the player,if you call init every frame, dosen't that reset your movement ? "btn(0) -= player1.x" ?

I have always trouble with global and local variables.

@ertifiedloaf I'm curious, what's this game when it's running. I wasn't brave engough to post an unfinished game with multiple map(x,y) and some ghostcollisions. Now I follow your game.


Hey Zellente, sorry for the late reply! The game is a project for my multimedia project at school, I'm aiming to make it similar to the minigames in Yoshi's Island!


No Problem uncertifiedloaf, I have a life too. Is there an update coming for this game?

I played Super Mario on SNES, loved this green dinosaur,...[old man gibberish].. For the minigames I need a video or two.

Funny that this BBS post recently came up Frog Game that has some tongue mechanics, where now I hear Yoshi animation sounds.


if anyones still subbed to this thread, i cant figure out how to get the player1 and player2 to have gravity, movement, etc when the game starts... any ideas?


As I mentioned before, the init_game() seems to overwrite your x,y position every frame to the init values for player1/player2 -> no movement

I removed the two init_game() from every other position in code and placed it to the menue selection

function menu()
 -- press up to move up the menu
 if(btnp(2)) then
 	selectedtile-=1

 -- press down to move down the menu
 elseif(btnp(3)) then
 	selectedtile+=1	

 -- press 🅾️ to select the menu item
 -- this changes the gamestate strings
 -- so now, the update runs that section instead
 elseif(btnp(4)) then
  if(selectedtile==1)then
   gamestate = 'throw'
--change
   init_game() 
  elseif(selectedtile==2)then
   gamestate = 'seed spit'
--change
   init_game()
  elseif(selectedtile==3)then
   gamestate = 'melon steal'
--change
  init_game()
  elseif(selectedtile==4)then
   gamestate = 'coins'
--change
   init_game()
  end
 end

in gamemode throw, the one grey player moves/falls now


appreciate it zellente!


back again zellente, just tried it today as I had some free time, and I don't know how, but I did what you said: removed all other init_game() and added them into the menu selection, but now when I select throw, the pink character falls instead of the grey one...

did I do something wrong? how do I get both to move?


hi again. I'm sorry but there is so much physics going on and 2 players...what pink player,they are both grayish.
Maybe you could reduce the code to something less complicated? I still do not know what throw game mode is all about.

(needs 2 sprites in a new chart)
´´´ function _init()
ply2_x = 0
ply1_x = 0
grav = -0.2
end

function _draw()
cls()

spr(1,ply1_x,5)
spr(2,ply2_x,15)
end

function _update()
player 1 movement
if btn(➡️,0) then
ply1_x+=1
end
if btn(⬅️,0) then
ply1_x-=1
end

--same for player 2
if btn(➡️,1) then
ply2_x+=1
end
if btn(⬅️,1) then
ply2_x-=1
end

--gravity
ply1_x-=grav
ply2_x-=grav
end´´´



[Please log in to post a comment]