I NEED HELP (pls)

@Killer.Jo I don’t know what this is supposed to do, but it seems to be working ok. Again, you’re posting code that you say doesn’t work, but we don’t know what it’s supposed to do to begin with. You code buttons that do things but what they’re supposed to do, who knows.

@dave1707 @Bri_G

All things that don’t work: If you type something at the very beginning and then click Enter, you will be redirected to the menu. The problem with the menu is that when you click on “Iceland” or under “Iceland”, you come back where you can enter something. And you shouldn’t come back. 2. Error in the code that I could not solve: If you click on the “x” button, you cannot return to the main menu. But you should return to the menu. If I couldn’t explain it well, it would be due to the translator because he doesn’t work so well

You know how to make buttons. You know how to go to a new screen when a button is pressed. You know how to go from a new screen back to an old screen or to another screen. You have all the knowledge on how to jump from screen to screen, you just need to layout what you want to do. That’s where a flow chart comes in handy. Draw what you want to do and write the code to do it. Giving us buttons that go to screens and then saying it doesn’t work doesn’t help us. You keep coming up with different screens and different buttons that do different things and want us to figure out why it doesn’t work. What are you trying to do with the different screens and buttons.

  1. You should have a main menu screen.
  2. That screen has buttons on it.
  3. Each of those buttons do something.
  4. If they take you to a new screen, what does that screen do. Does it have buttons that take you back to the menu or to another screen. Or does it get input from the keyboard.
  5. You need to know what you want to do at each screen or for each button.

@Killer.Jo - picking up on @dave1707 s reply to you - before you start programming a project you need to have a very good idea of what your project will look like when finished.

You need to know what stages are going to be present, what each stage does, how you move between stages (like splash screen, game and win/lose page) which gives you ideas on your way forward with development.

Then you need to understand what your programming language needs to do, at each stage, to be able to run correctly.

This means you need to understand how Codea works. We have all had to go through the same learning curve, some people pick it up quickly others slower. Having programmed before in other languages can help.

So for Codea - the best general structure for projects is based on functions. Some of these are built into Codea and are important to get the best out of your project. Most projects introduce lots of other functions, you develop yourself, to carry out features of your project.

Here are the generally fixed more common functions that Codea uses:

Function setup() - this defines the variables and links the assets you will use for your project. It is the first function that Codea runs and runs only once.

Function draw() - this function is called by Codea refreshing the screen about 60 times a second and is there to generate what you see on the screen. Placing lots of other code in this function can lead to it being cluttered and difficult to read/edit if it gets too complicated. So commands here concentrate on the drawing functions.

Function touched(touch) - is how you interact with your project when you touch the screen. Checking on where, when and how frequently you touch it and with how many points of touch you make. It uses that to respond by changing variables in you project to produce effects in the draw() function or with sound. Also its use triggers a variable change to switch between stages of your project.

Function update() - is used sometimes to help make changes to your screen which you check after every pass of the draw() function.

You may create your own functions, which you call from the draw() function to make you project easier to follow.

Indenting your code is also a good way to make the project easier to follow, understand and correct errors.

So - your best way forward is to set up the separate stages so that you. can flip between them without problems. Then, work on each stage to make your project come to life. Be patient, don’t try to rush it as, if you introduce errors they can make correcting them difficult and time consuming.

You will always find help and example code here (from the forum archives and support documents) that can ease you through problems.

@Bri_G @dave1707 Ok. So I will draw things that should appear in my game. I used to do that at school.

@Killer.Jo - that’s a good start. The next step would be a diagram showing the directions and content of each part and their interactions. No detail at this stage just the direction and triggers needed for change. This is effectively a flow chart.

Another tip, I note in your projects you place sprites with absolute coordinates ie numbers. This obviously works but if you set up a variable vector2 in setup you can use that - it’s easier to remember and makes it easier to read and understand your code, especially if you didn’t write it yourself.

Example - in setup()

button1 = vec2(400, 350)

In draw()

sprite(squarebutton, button1.x, button1.y)

I made a movment system:


 Chrakter

function setup()
    Charaktere = {
        asset.builtin.Planet_Cute.Character_Boy
    }
    x = 10
    y = 10
    
    time = os.date("*t")
stunde = time.hour
minute = time.min
end

function draw()
    background(0)
    sprite(asset.builtin.Planet_Cute.Character_Boy, y, x)
    
    
    sprite(asset.builtin.Blocks.Cactus_Inside, 200, 250, 250, 400)
    sprite(asset.builtin.UI.Blue_Button_07, 200, 420)
    sprite(asset.builtin.UI.Blue_Button_07, 300, 250)
    sprite(asset.builtin.UI.Blue_Button_07, 100, 250)
    sprite(asset.builtin.UI.Blue_Button_07, 200, 100)
    
     if CurrentTouch.state == MOVING then        
        if CurrentTouch.x >= 200-120 and CurrentTouch.x <= 200+120 and 
            CurrentTouch.y >= 420-49 and CurrentTouch.y <= 420+49 then   
            x = x + 5
            sprite(asset.builtin.UI.Red_Button_07, 200, 420)
        end 
        end     
        
     if CurrentTouch.state == MOVING then        
        if CurrentTouch.x >= 200-120 and CurrentTouch.x <= 200+120 and 
            CurrentTouch.y >= 100-49 and CurrentTouch.y <= 100+49 then   
            x = x - 5
            sprite(asset.builtin.UI.Red_Button_07, 200, 100)
        end 
    end 
    
    if CurrentTouch.state == MOVING then        
        if CurrentTouch.x >= 300-120 and CurrentTouch.x <= 300+120 and 
            CurrentTouch.y >= 250-49 and CurrentTouch.y <= 250+49 then   
            y = y + 5
            sprite(asset.builtin.UI.Red_Button_07, 300, 250)
        end 
    end 
    
    if CurrentTouch.state == MOVING then        
        if CurrentTouch.x >= 100-120 and CurrentTouch.x <= 100+120 and 
            CurrentTouch.y >= 250-49 and CurrentTouch.y <= 250+49 then   
            y = y - 5
            sprite(asset.builtin.UI.Red_Button_07, 100, 250)
        end 
        end 
    -- rechts
    
    text("Bewege deinen immer Finger zu den Buttons!", 525, 700)
 
    
    fill(255, 249, 0)
    font("Arial-BoldMT")
    fontSize(20)
text("Uhrzeit " .. stunde .. ":" .. minute,200, 800)
    
    text("")
    
    sprite(asset.builtin.Planet_Cute.Enemy_Bug, 550, 300)
    
    if CurrentTouch.state == ENDED then        
        if CurrentTouch.x >= 300-120 and CurrentTouch.x <= 300+120 and 
            CurrentTouch.y >= 250-49 and CurrentTouch.y <= 250+49 then   
            
        end 
    end 
end

Good job on the movement. But you’re back to using current touch again instead of the touched function. So here’s what I’m going to do. If you continue to use current touch, I’m going to ignore any help you want for that code.

@dave1707 I created the code earlier. Because I used to use Current Touch

You did a great job with the movement. Now just take that code and change it to use the touched function so you get used to using it.


WachenX = 900
WachenY = 700

shootX = x
shootY = y

WshootX = WachenX
WshootY = WachenY

WachenLeben = 1
if Training then
        background(77)  
        sprite(asset.builtin.UI.Blue_Button10, 850, 100, 100)
        if not nicht then 
        shootX = shootX + 30
    end 
        
        sprite(asset.builtin.Planet_Cute.Character_Boy,x,y) 
        
        if not loeschen then
    sprite(asset.builtin.Planet_Cute.Character_Horn_Girl, WachenX, WachenY, 100)
            end
        fill(255, 14, 0)
        text(WachenLeben, WachenX, WachenY)
        fill(37, 0, 255)
        fontSize(20)
        text(SpielerLeben, 100, 100)
        sprite(asset.builtin.Planet_Cute.Brown_Block, 150, 715, 100)
        sprite(asset.builtin.Space_Art.Green_Bullet, WshootX, WshootY)
        Counter = Counter + 1      
        WshootX = WshootX - 40
    
        if Counter > 60 then
            WshootX = WachenX
            
            Counter = 0
        end
        
        --Los Angeles Jugend Johann Game Timeddd.  dieser ext. stante EinfaäÄVH Ähier. 
        checkCollide() 
    end
    
    
    
    sprite(asset.builtin.UI.Blue_Tick, shootX, shootY) 
    
    
 
    
    if RND == "Tod" then
       background(0)
        fill(255, 14, 0) 
        ellipse(100,100)
        text("Wird ins Krankenhaus verlagert..", 500, 400)
    end
    
    if RND == "Kill" then
       sprite(asset.builtin.Planet_Cute.Shadow_North_East, WachenX, WachenY, 100)
        loeschen = true
        WachenX_sgk = 0 
        Wshoot = WachenX
    end

    
    function shooting()
    shootX = shootX + 30
    nicht = false
    shootY = y
   
        
end
 
if SpielerLeben then
    background(0)
end

I just can’t get the guard to shoot the player correctly (so the guard should shoot in the direction of the player)

Edit: Is there anyone else here?