Writing a 2048 game for final project, have a couple questions.

Hello everyone, I decided to make 2048 for my final project in my c++ class, and I need some advice before I start getting into the nitty gritty. I currently have a 4x4 array with all the values initialized to 0 as the game board and I have a couple questions.

a) How can I get a random index in the array and put a 2 in it?


b) What would the algorithm look like for moving up down left right?
ans 1)

int x =rand()%number

will give assign a random number from 0-number to x
and you can assign that postion like a[x] =2;

ans 2) I dont know what do you exactly want , but have you built a simple ascii
dungeon crawler in c++ ??
Topic archived. No new replies allowed.