{"id":26745889,"url":"https://github.com/mmmries/tankinho","last_synced_at":"2025-03-28T08:19:44.696Z","repository":{"id":44755192,"uuid":"137716828","full_name":"mmmries/tankinho","owner":"mmmries","description":"a tank game client that works with rrobots","archived":false,"fork":false,"pushed_at":"2018-08-25T06:14:17.000Z","size":18,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-03-11T16:08:04.882Z","etag":null,"topics":["elixir","game","tank","tank-game","udp","udp-client"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mmmries.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-18T06:23:45.000Z","updated_at":"2018-08-24T12:52:19.000Z","dependencies_parsed_at":"2022-09-03T05:02:26.371Z","dependency_job_id":null,"html_url":"https://github.com/mmmries/tankinho","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmmries%2Ftankinho","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmmries%2Ftankinho/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmmries%2Ftankinho/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmmries%2Ftankinho/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmmries","download_url":"https://codeload.github.com/mmmries/tankinho/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245991536,"owners_count":20706129,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","game","tank","tank-game","udp","udp-client"],"created_at":"2025-03-28T08:19:44.217Z","updated_at":"2025-03-28T08:19:44.688Z","avatar_url":"https://github.com/mmmries.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tankinho\n\nA sample UDP client for playing [rrobots](https://github.com/mmmries/rrobots).\nYou can see a demo of the game [here](https://youtu.be/MWC36pFxUrs).\n\n## Getting Started\n\nIf you are playing the game on your own you will first need to [get a server started](https://github.com/mmmries/rrobots#usage).\nIf you are playing in a group you just need to get the address of the server.\n\nNow you can clone this repo and run it as an example like this:\n\n```\n$ git clone https://github.com/mmmries/tankinho.git\n$ cd tankinho\n$ mix do deps.get, compile\n$ mix run client.exs --server 192.168.2.10:5566 --name Michael\n```\n\nJust replace the server address and name above with the address where the server is running and the name you want your tank to have in the game.\n\n## Customizing Your Tank\n\nThe default tank implementation is in `MyTank.ex`.\nOpen that file and you can see a template.\nThe basic idea is that you have a module with two functions:\n\n * `init/1` function which is called when you join a game\n * `tick/2` function which is called once on each tick of a game\n\n ## Init Function\n\n The init function receives a single argument like:\n\n ```elixir\n%{\n  width:  800, #the height of the game in pixels\n  height: 600, #the width of the game in pixels\n  size:   60,  #the height/width of your robot in pixels\n}\n ```\n\n This function will return a `state` term of anything you want to keep track of for the game.\n This same `state` will be passed to your `tick` function on the first tick of the game.\n\n ## Tick Function\n\nThe tick function is called 60 times per second (once for each frame of the game) and receives two arguments.\nThe first argument is the game state from the server (see details below).\nThe second argument is the current `state` of your tank.\n \nThe tick function is where your tank decides to take actions like turning, driving and shooting.\nEach time your function is called it must return a tuple of: `{actions, new_state}`, and the `new_state` will be passed as the second argument the next time your `tick` function is called.\n\nThe `actions` you want to take is a `%Tankinho.Actions{}` struct.\nYou can take actions like this: `%Actions{} |\u003e Actions.fire(1) |\u003e Actions.accelerate(2.0)`.\nFor a full list of actions you can take, please see [the Actions module](https://github.com/mmmries/tankinho/blob/master/lib/tankinho/actions.ex).\n\n## The Game State\n\nThe game state from the server provides information about where the tank is,\nhow much energy it has, and other details about the game board.\nHere is an example of what the data looks like.\n\n ```elixir\n%{\n  \"energy\" =\u003e        100,\n  \"gun_heading\" =\u003e   242.0,\n  \"heading\" =\u003e       242.0\n  \"radar_heading\" =\u003e 242.0,\n  \"time\" =\u003e          416,\n  \"speed\" =\u003e         0,\n  \"x\" =\u003e             1764.0,\n  \"y\" =\u003e             60.0,\n  \"robots_scanned\":  [1020.65],\n  \"broadcasts\":      [[\"hi\", \"west\"]],\n}\n ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmmries%2Ftankinho","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmmries%2Ftankinho","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmmries%2Ftankinho/lists"}