Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

TokOut's collection

AnatolyAnatoly Mod
edited December 2015 in Code Sharing Posts: 848

hello, it's me, I had the idea for this code to share funny codes. So here is my one:

I call it the Smaragd Generator
Description: It will rotate a Smaragd in different rotations by creating a speed rotate and looks nice.

function setup()
    parameter.watch("x")
    parameter.watch("d")
end

function draw()
    if x==nil then x=10 d=true end
    if d==true then x=x+10 else x=x-10 end
    if x>=300 then d=false end
    if x<=0 then d=true end
    background(30, 255, 50, 255)
    translate(WIDTH/2,HEIGHT/2)
    rotate(ElapsedTime * x, 50, 100, 500)
    fill(255, 255, 0, 255)
    rect(-100, -100, 200, 200)
end

This isn't any competition. Just share funny codes with nice animation. Not, really, don't you like the idea, instead of creating topics for one class, sharing them here.

After removing the background,..

Tagged:
«1

Comments

  • Jmv38Jmv38 Mod
    Posts: 3,295

    @TokOut hello! Why dont you put everything you are doing in this post, including your remarks, comments, error messages, moods? This way it will be easier to follow all your creations. You are kind of spamming the forum now, i would love to have all your comments in one single place so i can more easily follow your creativity.
    Thanks!

  • Posts: 2,020

    I agree with @Jmv38 . The reason we keep closing your threads is the you make multiple threads on the same topic, about the same code repository. Codea Talk is not meant to be "The TokOut Show".

    On the right-hand side of the screen, there is a "My Discussions" button. Please use this to find your previous threads. If you want to announce a change or discuss an issue with something you're working on, do that with a post in the original thread you started. Do not make a new thread. It is much easier for people to follow the conversation and understand what the issue is if the discussion happens in one place. If you start several threads a day, people will think you're a spammer and ignore you.

  • AnatolyAnatoly Mod
    edited December 2015 Posts: 848

    @yojimbo2000, @Jmv38, I want to suggest the category's:
    Off-Topic -> Won't be seen in General Screen,
    Codea-Category -> it's the Codea category

    Subcategory's:
    • For: Code Sharing
    Simple Codes, Windows, Math, Fun
    • For: Bugs
    Crashes Codea, Tags Bug Eg.: The bug which was fixed about matrix * vec3, forum
    • For: Suggestions
    Tags, Graphics, Forum
    • For: Questions
    Developer Questions, Other

  • AnatolyAnatoly Mod
    Posts: 848

    @yojimbo2000, question: Any server game instead of an server Bluetooth. Is it possible?

  • AnatolyAnatoly Mod
    edited December 2015 Posts: 848

    @yojimbo2000, @Jmv38, you want to know my things: The code is here, the video I will give later (5 minutes)

    https://github.com/TokOut/calculator/tree/master/version-2-0

  • AnatolyAnatoly Mod
    Posts: 848

  • Jmv38Jmv38 Mod
    Posts: 3,295

    nice! Keep putting your stuff in this thread.

  • AnatolyAnatoly Mod
    Posts: 848

    Thx <3

  • AnatolyAnatoly Mod
    Posts: 848

    And @jmv38, can you say to yojimbo2000 that if this thread will be old not to close this, ok?

  • AnatolyAnatoly Mod
    Posts: 848

    In this code I found out how to work with strings and the diagonal script line \\
    Use...
    \f, \n, \r for a new line
    \t for a long space (x\ty -> x y)
    \v for a short space (x\ty -> x y)


    function draw() --[[ case '"': printf("\\\""); break; case '\\': printf("\\\\"); break; case '\a': printf("\\a"); break; case '\b': printf("\\b"); break; case '\f': printf("\\f"); break; case '\n': printf("\\n"); break; case '\r': printf("\\r"); break; case '\t': printf("\\t"); break; case '\v': printf("\\v"); break; ]] background(0, 0, 0, 255) text("dfhfxvvg\addddd\banytext\fmoretext\nmoretext\rmoretext\tmoretext\vmoregext", WIDTH/2, HEIGHT/2) -- \f \n \r - new line -- \t - longer space -- \v - smaller space end
  • AnatolyAnatoly Mod
    Posts: 848

    My first table code @yojimbo2000, like you wanted



    function setup() tbl = {} end function draw() background(0, 0, 0, 255) fill(127, 127, 127, 255) stroke(255, 255, 255, 255) strokeWidth(1) for x = 1, 25 do tbl[x] = {} for y = 1, 25 do tbl[x][y] = false rect(x * 20, y * 20, 25, 25) end end end
  • AnatolyAnatoly Mod
    Posts: 848

    @Ignatz, @yojimbo2000, @dave1707, @jmv38, you wanted that I will keep my codes here, this is my next table lesson: Iron background:

    function setup()
        displayMode(OVERLAY)
        displayMode(FULLSCREEN)
        s = 50
        bg = {}
    end
    
    function draw()
        -- You can set the background to any value, for not repeating bodys
        background(0, 0, 0, 255)
        fill(127, 127, 127, 255)
        stroke(255, 255, 255, 255)
        strokeWidth(1)
    
        for x = 1, 25 do bg[x] = {} for y = 1, 25 do bg[x][y] = false
            rect(x * s - 105, y * s - 105, s, s)
        end end
        -- Do your drawing here
    end
    
  • AnatolyAnatoly Mod
    Posts: 848

    This code is bugging: Can someone help plz?

    function setup()
        bg = {}
    end
    
    function draw()
        background(0, 0, 0, 255)
        for x = 1, 100 do
            bg[x] = {}
            for y = 1, 75 do
                bg[x][y] = false
                fill(math.random(255), math.random(255), math.random(255), 255)
                ellipse(WIDTH/2, HEIGHT/2, x * 5, y * 5)
            end
        end
    end
    
  • Posts: 116

    @TokOut, you should set the array in the setup() and only draw in draw(). So bg[x]={} shoulnt be in draw but in setup

  • Posts: 2,020

    @TokOut what is the problem with the code? It does exactly what you've told it to do, which is draw 7500 overlapping ellipses in the centre of the screen every frame.

  • AnatolyAnatoly Mod
    Posts: 848

    He isn't drawing ellipses in random position.

  • Posts: 2,020

    You haven't told it to draw ellipses in random positions, you've told it to draw them all at width/2, height/2. They all overlap, so you only really see one ellipse. You've set the color to be random. Code will only do exactly what you tell it to do, not what you think you might want it to do.

  • AnatolyAnatoly Mod
    Posts: 848

    Oh, overseen

  • AnatolyAnatoly Mod
    Posts: 848

    @yojimbo2000, how to make a code, that if you will do something, an e-mail will be sent, for example

    if CODE-IS-WORKING elseif CODE-IS-WORKING else
    REQUEST-TO-OWNER
    as Request To Owner is the moment where we sent the e-mail
  • AnatolyAnatoly Mod
    edited December 2015 Posts: 848

    How to make that touch state hold? I am working on a project like Minecraft 2d and want instead moving in the buttons to make them only hold to move, then I'd also like knowing how to make that he can only move on the world option. The graphics are in the video bad. This is a small 25x25 big world and there is a body moving

  • Posts: 2,020

    With a mailto openurl call. Have a look at this thread:

    https://codea.io/talk/discussion/1123/the-power-of-openurl

  • AnatolyAnatoly Mod
    Posts: 848

    In the urn I had this bug (by using the code):

  • AnatolyAnatoly Mod
    Posts: 848

    The picture does not seem to be uploaded

  • AnatolyAnatoly Mod
    Posts: 848

    So, he said: UNEXPECTED SYMBOL NEAR '<\194>' - so I could not open the project

  • AnatolyAnatoly Mod
    Posts: 848

    @yojimbo2000, @ignatz, why Codea hasn't got any reference for io, assert, type and many other tags, why isn't there any reference?

  • dave1707dave1707 Mod
    Posts: 7,807

    @TokOut It takes time to write documentation and the developers can't add new functions to Codea and write documentation for everything. A lot of information can be found in the Lua reference. If you want to write documentation for anything not in the reference, you can. If it's written well enough, the developers could add it to the reference.

  • AnatolyAnatoly Mod
    Posts: 848

    But @dave1707, I have found an documention for io.lines
    It was something like for line in io.lines do and in the example he would draw many lines. But actually he didn't Drawen anything. I thought something like not all tags where programmed for lua. For the tag typeits something like a nil tag. It is only highlighted. I will try to find something..

  • AnatolyAnatoly Mod
    Posts: 848

    I found a documentation for assert: http://luatut.com/assert.html

  • AnatolyAnatoly Mod
    Posts: 848

    Here is a documentation for io http://www.lua.org/pil/21.2.html , but I didn't understand anything

  • IgnatzIgnatz Mod
    Posts: 5,396

    Why don't you try just learning basic Lua first?

  • AnatolyAnatoly Mod
    Posts: 848

    I learned tables, what know?

  • IgnatzIgnatz Mod
    Posts: 5,396

    meshes, vectors, then practise, practise, practise until you are good at programming all these things

  • AnatolyAnatoly Mod
    edited December 2015 Posts: 848

    @mentioned; This is my code, I was trying to understand why by touching DOWN, It will go UP

        if self.hold then
            if self.holdMode == UP then
                self.body:move(0, 3)
            elseif self.holdMode == DOWN then
                -- Problem point TO-FIX [He is going Up!]
                self.body:move(0, -3)
            elseif self.holdMode == RIGHT then
                self.body:move(3, 0)
            elseif self.holdMode == LEFT then
                self.body:move(-3, 0)
            end
        end
    

    The class self.body:move has got x and y attributes so you have to reset -3 to go down but wether 3 or -3 is working

    More code: The Body:move function:

    function Body:move(x, y)
        if x == nil then x = 0 end
        if y == nil then y = 0 end
        self.x = self.x + x
        self.y = self.y + y
    end
    

    More code: The touched function


    function World:touched(t) if t.state == BEGAN then if t.x>25 and t.x<75 and t.y>25 and t.y<75 then -- LEFT self.holdMode = LEFT self.hold = true elseif t.x<150 and t.x>100 and t.y<75 and t.y>25 then -- DOWN self.holdMode = DOWN self.hold = true elseif t.x>175 and t.x<225 and t.y>25 and t.y<75 then -- RIGHT self.holdMode = RIGHT self.hold = true elseif t.x>100 and t.x<150 and t.y>100 and t.y<150 then -- UP self.holdMode = UP self.hold = true end elseif t.state == ENDED then self.hold = false end end
  • AnatolyAnatoly Mod
    Posts: 848

    I want to present you the Simple Windows:
    https://github.com/TokOut/The-Great-Work/tree/master/Win

  • AnatolyAnatoly Mod
    edited January 2016 Posts: 848

    I need help! I have trouble with window moving! Can someone say me the problem? When I move the window he got stuck at many points! But I need to have a move without stuck points, I removed the thing. Here is the main code:

    Window = class()
    
    function Window:init()
        self.drawing = true
        self.pos = vec2(0, 0)
        self.size = vec2(400, 250)
        self.logo = readImage("Cargo Bot:Codea Icon")
        self.action = function() print("The window was clicked!") end
        self.name = "Test Window"
        self.fontSize = 25
        self.closeable = true
        self.logo_size = 45
    end
    
    function Window:draw()
        if self.drawing then
            fill(255, 255, 255, 255)
            rect(self.pos.x, self.pos.y, self.size.x, self.size.y)
            stroke(0, 0, 0, 255)
            strokeWidth(2.5)
            line(self.pos.x, self.pos.y+self.size.y-50, self.pos.x+self.size.x, self.pos.y+self.size.y-50)
            sprite(self.logo, self.pos.x + 25, self.pos.y+self.size.y-25, self.logo_size, self.logo_size)
            fill(0, 0, 0, 255)
            font("AmericanTypewriter")
            fontSize(self.fontSize)
            text(self.name, self.pos.x+self.size.x/2, self.pos.y+self.size.y-25)
            if self.closeable then
                fill(255, 0, 0, 255)
                stroke(0, 255, 50, 255)
                strokeWidth(1)
                rect(self.pos.x+self.size.x-45, self.pos.y+self.size.y-45, 40, 40)
                fill(255, 255, 255, 255)
                font("AmericanTypewriter-Bold")
                fontSize(40)
                text("X", self.pos.x+self.size.x-25, self.pos.y+self.size.y-25)
            end
        end
    end
    
    function Window:touched(t)
        if t.state == BEGAN and self.drawing then
            if t.x>self.pos.x and t.x<self.pos.x+self.size.x and t.y>self.pos.y and t.y<self.pos.y+self.size.y then
                self.action()
                if self.closeable and t.x>self.pos.x+self.size.x-45 and t.x<self.pos.x+self.size.x-5 and t.y>self.pos.y+self.size.y-45 and t.y<self.pos.y+self.size.y-5 then
                    print("Window Closed!")
                    self.drawing = false
                end
            end
        end
    end
    
  • dave1707dave1707 Mod
    Posts: 7,807

    Put this code in Window:touched(t). I don't know why you can't figure this out yourself.

        if t.state == MOVING and self.drawing then
            if t.x>self.pos.x and t.x<self.pos.x+self.size.x and t.y>self.pos.y and t.y<self.pos.y+self.size.y then
                self.pos=vec2(t.x-200,t.y-125)
            end
        end
    
  • AnatolyAnatoly Mod
    Posts: 848

    Oh, I didn't thought about vectors :(

  • AnatolyAnatoly Mod
    Posts: 848

    Hurray! I learned meshes!

  • dave1707dave1707 Mod
    Posts: 7,807

    @TokOut You said you didn't think about vectors, yet the code you posted has vec2's and you're using them all over the place.

  • AnatolyAnatoly Mod
    Posts: 848

    @dave1707 yes but I thought about t.x + 1 = self.pos.x + 1 which was bugging

    I need help with meshes, I expected a rect:

    function setup()
        m = mesh()
        m.vertices = {vec3(0, 0 , 0), vec3(WIDTH, 0, 0), vec3(WIDTH, HEIGHT, 0), vec3(0, HEIGHT, 0)}
        m.colors = {color(255, 255, 255, 255), color(223, 216, 145, 255), color(167, 255, 0, 255), color(239, 0, 255, 255)}
    end
    
    function draw()
        background(0, 0, 0, 255)
        m:draw()
    end
    
  • IgnatzIgnatz Mod
    edited January 2016 Posts: 5,396

    You don't understand meshes, if you think 4 vertices is ok. You need 6.

    I think you should go back and read some more about them

  • AnatolyAnatoly Mod
    Posts: 848

    K

  • AnatolyAnatoly Mod
    Posts: 848

    I made a scroll for people who needs:

    function AllDiscussions:touched(t)
        -- Action List
        self.testdiscussion:touched(t)
        -- Main Action
        if t.state == ENDED then
            self.touch = false
            local currentY = 0
        else
            if t.y < 650 then
                self.touch = true
                local currentY = t.y
                translate(0, currentY)
                if currentY > self.y then
                    self.y = self.y + t.deltaY/2
                else
                    self.y = self.y - t.deltaY/2
                end
                translate(0, -currentY)
            end
        end
    end
    
  • AnatolyAnatoly Mod
    Posts: 848

    A forest background for people who needs:

    displayMode(FULLSCREEN)
    
    function setup()
        z = 50
        tab = {}
    end
    
    function draw()
        background(0, 0, 0, 255)
        for x = 0.6, 25 do
            tab[x] = {}
            for y = 0.5, 15 do
                -- First triangle
                stroke(0, 255, 0, 255)
                strokeWidth(5)
                line(x * z, y * z, x * z + 10, y * z)
                line(x * z, y * z, x * z + 5, y * z + 5)
                line(x * z + 5, y * z + 5, x * z + 10, y * z)
                -- Second triangle
                v = 9.5
                line(x * z, y * z + v, x * z + 10, y * z + v)
                line(x * z, y * z + v, x * z + 5, y * z + v + 5)
                line(x * z + 5, y * z + v + 5, x * z + 10, y * z + v)
                -- Wooden
                stroke(75, 50, 25, 255)
                strokeWidth(6.5)
                line(x * z + 5, y * z, x * z + 5, y * z - 10)
            end
        end
    end
    
  • AnatolyAnatoly Mod
    Posts: 848

    I released a forum for people who needs:

    --Installer
    --Known issue: the code being installed should have its Main tab as the left-most tab
    
    local function success(data)
        if data:find("%-%-%# Main") then --paste-into-project format
            data = data.."--# " --add new file tag to end in order to capture last file
            for name, file in data:gmatch("(%w+)\n(.-)\n%-%-%# ") do --capture each name and file
                saveProjectTab(name, file)
                print("Saved", name)
            end
        else --put it all in one tab
            saveProjectTab("Main", data)
        end
        load(data)() --load the file
        setup() --run it
    end
    
    local function failure(error)
        print("Error", error)
    end
    
    http.request("https://gist.github.com/TokOut/86801d2085e3bc7334e8", success, failure)
    
  • AnatolyAnatoly Mod
    edited January 2016 Posts: 848

    Deleted

  • AnatolyAnatoly Mod
    Posts: 848

    Sorry, autogist doesn't work {=< Use this URL:
    https://gist.github.com/TokOut/86801d2085e3bc7334e8

  • Posts: 2,020

    @TokOut the installer that you used here:

    https://codea.io/talk/discussion/comment/66517/#Comment_66517

    Isn't working because the URL needs to be to the raw version of the file (from the gist page, press the "raw" button, then use that URL). Generally, using http.request to grab a file, you need a raw URL (ie a page that has just the content and nothing else)

  • AnatolyAnatoly Mod
    edited January 2016 Posts: 848

    Ok, so you have just to copy this code and put it in any project:

    https://gist.github.com/TokOut/86801d2085e3bc7334e8

    @yojimbo2000, what do you think? Is it bad? Or good?

Sign In or Register to comment.